From 888a5a5ed675ab468054b522a673e44661d5cdc2 Mon Sep 17 00:00:00 2001 From: eosfor <9363027+eosfor@users.noreply.github.com> Date: Wed, 26 Mar 2025 07:40:24 +0000 Subject: [PATCH 1/2] exersize --- .../architectureVerification.Rule.ps1 | 34 -- .../local.ArchitectureVerification.Rule.ps1 | 3 + scripts/psrule-demo/.ps-rule/main.json | 415 ------------------ scripts/psrule-demo/.ps-rule/verifyRule.ps1 | 5 - .../{ => deployments/non-prod}/main.bicep | 31 +- scripts/psrule-demo/ps-rule.yaml | 44 +- scripts/psrule-demo/readme.md | 41 ++ 7 files changed, 71 insertions(+), 502 deletions(-) delete mode 100644 scripts/psrule-demo/.ps-rule/architectureVerification.Rule.ps1 create mode 100644 scripts/psrule-demo/.ps-rule/local.ArchitectureVerification.Rule.ps1 delete mode 100644 scripts/psrule-demo/.ps-rule/main.json delete mode 100644 scripts/psrule-demo/.ps-rule/verifyRule.ps1 rename scripts/psrule-demo/{ => deployments/non-prod}/main.bicep (54%) create mode 100644 scripts/psrule-demo/readme.md diff --git a/scripts/psrule-demo/.ps-rule/architectureVerification.Rule.ps1 b/scripts/psrule-demo/.ps-rule/architectureVerification.Rule.ps1 deleted file mode 100644 index 9db2e02..0000000 --- a/scripts/psrule-demo/.ps-rule/architectureVerification.Rule.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -Rule 'architecture.Verification.Rule' { - # Rule description - # Description = 'This rule checks the architecture of the template.' - - # Check for the presence of a VNet - $hasVnet = $TargetObject | Where-Object { $_.type -eq 'Microsoft.Resources/deployments' } | - Where-Object { $_.name -eq 'vnetDeployment' } | - Where-Object { $_.properties.template.resources.type -contains 'Microsoft.Network/virtualNetworks' } - - # # Look for a function - # $functions = $TargetObject | Where-Object { $_.type -like 'Microsoft.Web/sites' -and $_.kind -like '*functionapp*' } - - # # Check if there is app service VNet integration (resource type Microsoft.Web/sites/virtualNetworkConnections or a property inside the function) - # $hasVnetIntegration = $TargetObject | Where-Object { $_.type -like 'Microsoft.Web/sites/virtualNetworkConnections' } - - # # Look for a private endpoint for the function - # $hasPrivateEndpoint = $TargetObject | Where-Object { - # $_.type -eq 'Microsoft.Network/privateEndpoints' -and - # ($_.properties.privateLinkServiceConnections.properties.privateLinkServiceId -match ($functions.properties.id -replace '/$', '')) - # } - - # # Look for a Service Bus with Standard SKU - # $hasServiceBusStandard = $TargetObject | Where-Object { - # $_.type -eq 'Microsoft.ServiceBus/namespaces' -and $_.sku.name -eq 'Standard' - # } - - # Assertions: - # $hasVnet | Should -Not -BeNullOrEmpty -Because 'The template does not contain a virtual network.' - # $functions | Should -Not -BeNullOrEmpty -Because 'The template does not contain an Azure Function.' - # $hasVnetIntegration | Should -Not -BeNullOrEmpty -Because 'Azure Function VNet integration not found.' - # $hasPrivateEndpoint | Should -Not -BeNullOrEmpty -Because 'Private Endpoint for Azure Function not found.' - # $hasServiceBusStandard | Should -Not -BeNullOrEmpty -Because 'Service Bus does not have Standard SKU.' - #} -} \ No newline at end of file diff --git a/scripts/psrule-demo/.ps-rule/local.ArchitectureVerification.Rule.ps1 b/scripts/psrule-demo/.ps-rule/local.ArchitectureVerification.Rule.ps1 new file mode 100644 index 0000000..6eb7c12 --- /dev/null +++ b/scripts/psrule-demo/.ps-rule/local.ArchitectureVerification.Rule.ps1 @@ -0,0 +1,3 @@ +Rule 'local.Architecture.Verification' -Type 'Microsoft.Network/virtualNetworks' { + $Assert.HasFieldValue($TargetObject, 'name', 'vnetDeployment') +} \ No newline at end of file diff --git a/scripts/psrule-demo/.ps-rule/main.json b/scripts/psrule-demo/.ps-rule/main.json deleted file mode 100644 index 921083a..0000000 --- a/scripts/psrule-demo/.ps-rule/main.json +++ /dev/null @@ -1,415 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.34.44.8038", - "templateHash": "16321526849075088915" - } - }, - "parameters": { - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "functionName": { - "type": "string", - "defaultValue": "[format('myfunc{0}', uniqueString(resourceGroup().id))]" - }, - "planName": { - "type": "string", - "defaultValue": "[format('{0}-plan', parameters('functionName'))]" - }, - "serviceBusName": { - "type": "string", - "defaultValue": "[format('sb{0}', uniqueString(resourceGroup().id))]" - } - }, - "resources": [ - { - "type": "Microsoft.Resources/deploymentStacks", - "apiVersion": "2022-11-01", - "name": "myDeploymentStack", - "location": "[parameters('location')]", - "properties": { - "actionOnUnmanage": "delete", - "deploymentProperties": { - "mode": "Incremental", - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "resources": [ - "[reference(resourceId('Microsoft.Resources/deployments', 'vnetDeployment'), '2022-09-01')]", - "[reference(resourceId('Microsoft.Resources/deployments', 'subnetsDeployment'), '2022-09-01')]", - "[reference(resourceId('Microsoft.Resources/deployments', 'planDeployment'), '2022-09-01')]", - "[reference(resourceId('Microsoft.Resources/deployments', 'sbDeployment'), '2022-09-01')]" - ] - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'vnetDeployment')]", - "[resourceId('Microsoft.Resources/deployments', 'planDeployment')]", - "[resourceId('Microsoft.Resources/deployments', 'sbDeployment')]", - "[resourceId('Microsoft.Resources/deployments', 'subnetsDeployment')]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "vnetDeployment", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "location": { - "value": "[parameters('location')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.34.44.8038", - "templateHash": "12409449136509690176" - } - }, - "parameters": { - "location": { - "type": "string" - } - }, - "resources": [ - { - "type": "Microsoft.Network/virtualNetworks", - "apiVersion": "2022-01-01", - "name": "my-vnet", - "location": "[parameters('location')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "10.0.0.0/16" - ] - } - } - } - ], - "outputs": { - "vnetId": { - "type": "string", - "value": "[resourceId('Microsoft.Network/virtualNetworks', 'my-vnet')]" - }, - "vnetName": { - "type": "string", - "value": "my-vnet" - } - } - } - } - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "subnetsDeployment", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "location": { - "value": "[parameters('location')]" - }, - "vnetId": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'vnetDeployment'), '2022-09-01').outputs.vnetId.value]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.34.44.8038", - "templateHash": "6957783064439752939" - } - }, - "parameters": { - "location": { - "type": "string" - }, - "vnetId": { - "type": "string" - } - }, - "variables": { - "vnetIdSegments": "[split(parameters('vnetId'), '/')]", - "vnetName": "[last(variables('vnetIdSegments'))]" - }, - "resources": [ - { - "type": "Microsoft.Network/virtualNetworks/subnets", - "apiVersion": "2022-01-01", - "name": "[format('{0}/{1}', variables('vnetName'), 'function-integration-subnet')]", - "properties": { - "addressPrefix": "10.0.1.0/24" - } - }, - { - "type": "Microsoft.Network/virtualNetworks/subnets", - "apiVersion": "2022-01-01", - "name": "[format('{0}/{1}', variables('vnetName'), 'private-endpoint-subnet')]", - "properties": { - "addressPrefix": "10.0.2.0/24", - "privateEndpointNetworkPolicies": "Disabled" - } - } - ], - "outputs": { - "functionSubnetId": { - "type": "string", - "value": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), 'function-integration-subnet')]" - }, - "privateEndpointSubnetId": { - "type": "string", - "value": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), 'private-endpoint-subnet')]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'vnetDeployment')]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "planDeployment", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "location": { - "value": "[parameters('location')]" - }, - "planName": { - "value": "[parameters('planName')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.34.44.8038", - "templateHash": "6239492562769249215" - } - }, - "parameters": { - "location": { - "type": "string" - }, - "planName": { - "type": "string" - } - }, - "resources": [ - { - "type": "Microsoft.Web/serverfarms", - "apiVersion": "2022-03-01", - "name": "[parameters('planName')]", - "location": "[parameters('location')]", - "sku": { - "name": "Y1", - "tier": "Dynamic" - }, - "kind": "functionapp" - } - ], - "outputs": { - "planId": { - "type": "string", - "value": "[resourceId('Microsoft.Web/serverfarms', parameters('planName'))]" - } - } - } - } - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "sbDeployment", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "location": { - "value": "[parameters('location')]" - }, - "serviceBusName": { - "value": "[parameters('serviceBusName')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.34.44.8038", - "templateHash": "3205520425894265538" - } - }, - "parameters": { - "location": { - "type": "string" - }, - "serviceBusName": { - "type": "string" - } - }, - "resources": [ - { - "type": "Microsoft.ServiceBus/namespaces", - "apiVersion": "2022-10-01-preview", - "name": "[parameters('serviceBusName')]", - "location": "[parameters('location')]", - "sku": { - "name": "Standard", - "tier": "Standard" - } - } - ], - "outputs": { - "serviceBusId": { - "type": "string", - "value": "[resourceId('Microsoft.ServiceBus/namespaces', parameters('serviceBusName'))]" - } - } - } - } - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "functionDeployment", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "location": { - "value": "[parameters('location')]" - }, - "functionName": { - "value": "[parameters('functionName')]" - }, - "planId": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'planDeployment'), '2022-09-01').outputs.planId.value]" - }, - "functionSubnetId": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'subnetsDeployment'), '2022-09-01').outputs.functionSubnetId.value]" - }, - "privateEndpointSubnetId": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'subnetsDeployment'), '2022-09-01').outputs.privateEndpointSubnetId.value]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.34.44.8038", - "templateHash": "6724811079154947887" - } - }, - "parameters": { - "location": { - "type": "string" - }, - "functionName": { - "type": "string" - }, - "planId": { - "type": "string" - }, - "functionSubnetId": { - "type": "string" - }, - "privateEndpointSubnetId": { - "type": "string" - } - }, - "resources": [ - { - "type": "Microsoft.Web/sites", - "apiVersion": "2022-03-01", - "name": "[parameters('functionName')]", - "location": "[parameters('location')]", - "kind": "functionapp", - "properties": { - "serverFarmId": "[parameters('planId')]", - "siteConfig": { - "linuxFxVersion": "DOTNET|6.0" - }, - "httpsOnly": true - } - }, - { - "type": "Microsoft.Web/sites/virtualNetworkConnections", - "apiVersion": "2022-03-01", - "name": "[format('{0}/{1}', parameters('functionName'), 'vnet')]", - "properties": { - "vnetResourceId": "[parameters('functionSubnetId')]" - }, - "dependsOn": [ - "[resourceId('Microsoft.Web/sites', parameters('functionName'))]" - ] - }, - { - "type": "Microsoft.Network/privateEndpoints", - "apiVersion": "2022-01-01", - "name": "function-pe", - "location": "[parameters('location')]", - "properties": { - "subnet": { - "id": "[parameters('privateEndpointSubnetId')]" - }, - "privateLinkServiceConnections": [ - { - "name": "function-pe-connection", - "properties": { - "privateLinkServiceId": "[resourceId('Microsoft.Web/sites', parameters('functionName'))]", - "groupIds": [ - "sites" - ] - } - } - ] - }, - "dependsOn": [ - "[resourceId('Microsoft.Web/sites', parameters('functionName'))]" - ] - } - ] - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'planDeployment')]", - "[resourceId('Microsoft.Resources/deployments', 'subnetsDeployment')]" - ] - } - ] -} \ No newline at end of file diff --git a/scripts/psrule-demo/.ps-rule/verifyRule.ps1 b/scripts/psrule-demo/.ps-rule/verifyRule.ps1 deleted file mode 100644 index 79f1f41..0000000 --- a/scripts/psrule-demo/.ps-rule/verifyRule.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -# Read resources in from file -$resources = Get-Content -Path ./scripts/psrule-demo/rules/main.json | ConvertFrom-Json; - -# Process resources -$resources | Invoke-PSRule -Path ./scripts/psrule-demo/rules \ No newline at end of file diff --git a/scripts/psrule-demo/main.bicep b/scripts/psrule-demo/deployments/non-prod/main.bicep similarity index 54% rename from scripts/psrule-demo/main.bicep rename to scripts/psrule-demo/deployments/non-prod/main.bicep index 15798c1..7ad70a3 100644 --- a/scripts/psrule-demo/main.bicep +++ b/scripts/psrule-demo/deployments/non-prod/main.bicep @@ -4,14 +4,14 @@ param functionName string = 'myfunc${uniqueString(resourceGroup().id)}' param planName string = '${functionName}-plan' param serviceBusName string = 'sb${uniqueString(resourceGroup().id)}' -module network './modules/network.bicep' = { +module network '../../modules/network.bicep' = { name: 'vnetDeployment' params: { location: location } } -module subnets './modules/subnets.bicep' = { +module subnets '../../modules/subnets.bicep' = { name: 'subnetsDeployment' params: { location: location @@ -19,7 +19,7 @@ module subnets './modules/subnets.bicep' = { } } -module plan './modules/appserviceplan.bicep' = { +module plan '../../modules/appserviceplan.bicep' = { name: 'planDeployment' params: { location: location @@ -27,7 +27,7 @@ module plan './modules/appserviceplan.bicep' = { } } -module serviceBus './modules/servicebus.bicep' = { +module serviceBus '../../modules/servicebus.bicep' = { name: 'sbDeployment' params: { location: location @@ -35,7 +35,7 @@ module serviceBus './modules/servicebus.bicep' = { } } -module function './modules/functionapp.bicep' = { +module function '../../modules/functionapp.bicep' = { name: 'functionDeployment' params: { location: location @@ -45,24 +45,3 @@ module function './modules/functionapp.bicep' = { privateEndpointSubnetId: subnets.outputs.privateEndpointSubnetId } } - -resource stack 'Microsoft.Resources/deploymentStacks@2022-11-01' = { - name: 'myDeploymentStack' - location: location - properties: { - actionOnUnmanage: 'delete' - deploymentProperties: { - mode: 'Incremental' - template: { - '$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#' - contentVersion: '1.0.0.0' - resources: [ - network - subnets - plan - serviceBus - ] - } - } - } -} diff --git a/scripts/psrule-demo/ps-rule.yaml b/scripts/psrule-demo/ps-rule.yaml index af283f1..20a0b23 100644 --- a/scripts/psrule-demo/ps-rule.yaml +++ b/scripts/psrule-demo/ps-rule.yaml @@ -23,38 +23,38 @@ requires: PSRule.Rules.Azure: '@pre >=1.34.2' # Add PSRule v3 format configuration -format: - bicep: - type: - - '.bicep' - enabled: true - bicepparam: - type: - - '.bicepparam' - enabled: true +# format: +# bicep: +# type: +# - '.bicep' +# enabled: true +# bicepparam: +# type: +# - '.bicepparam' +# enabled: true # Use PSRule for Azure. -include: - module: - - PSRule.Rules.Azure +# include: +# module: +# - PSRule.Rules.Azure # Configure the output culture for recommendations. output: culture: - 'en-US' -input: - fileObjects: true - pathIgnore: - # Ignore other files in the repository. - - '**' +# input: +# fileObjects: true +# pathIgnore: +# # Ignore other files in the repository. +# - '**' - # Include deployments. - - '!deployments/**/*.bicepparam' - - '!deployments/**/deploy.bicep' +# # Include deployments. +# - '!deployments/**/*.bicepparam' +# - '!deployments/**/*.bicep' - # Include module tests. - - '!modules/**/*.tests.bicep' +# # Include module tests. +# - '!modules/**/*.bicep' configuration: # Enable automatic expansion of Azure parameter files. diff --git a/scripts/psrule-demo/readme.md b/scripts/psrule-demo/readme.md new file mode 100644 index 0000000..c8f604a --- /dev/null +++ b/scripts/psrule-demo/readme.md @@ -0,0 +1,41 @@ +# State of the art + +The powershell command below + +```powershell +cd /workspaces/scripting-notes/scripts/psrule-demo/ +Invoke-PSRule -Option ./ps-rule.yaml -InputObject . -Path ./.ps-rule -Verbose -Debug +``` + +return + +```console +Invoke-PSRule: Cannot process argument transformation on parameter 'Option'. Cannot convert value "./ps-rule.yaml" to type "PSRule.Configuration.PSRuleOption". Error: "Options file does not exist." +``` + +But i would expect it tu run successfully. + +Another attempt, with full paths + +```powershell +Invoke-PSRule -Option /workspaces/scripting-notes/scripts/psrule-demo/ps-rule.yaml -InputObject /workspaces/scripting-notes/scripts/psrule-demo -Path /workspaces/scripting-notes/scripts/psrule-demo/.ps-rule -Verbose -Debug +``` + +return + +```console +VERBOSE: [Invoke-PSRule] BEGIN:: +VERBOSE: [New-PSRuleOption] BEGIN:: +VERBOSE: [New-PSRuleOption] END:: +VERBOSE: [PSRule][D] -- Scanning for source files: /workspaces/scripting-notes/scripts/psrule-demo/.ps-rule +VERBOSE: [PSRule][D] -- Scanning for source files: .ps-rule/ +VERBOSE: [PSRule][D] -- Discovering rules in: /workspaces/scripting-notes/scripts/psrule-demo/.ps-rule/local.ArchitectureVerification.Rule.ps1 +VERBOSE: [PSRule][D] -- Found .\local.Architecture.Verification in /workspaces/scripting-notes/scripts/psrule-demo/.ps-rule/local.ArchitectureVerification.Rule.ps1 +VERBOSE: [PSRule][R][0][.\local.Architecture.Verification] :: db144ec1c65441c05eb49892888c704121ae5c84 +DEBUG: Target failed Type precondition +VERBOSE: [Invoke-PSRule] END:: +``` + +But my expectation here that it should find the rule, which it does, then it should run a rule, find a resource of a type `Microsoft.Network/virtualNetworks` which is defined in [modules/network.bicep](/scripts/psrule-demo/modules/network.bicep), and return `success`. + +The scenario is simple, there is an, say, Architect, who defines how a sertain solution shouls look in in Azure. Basically in most cases iti is a diagram in visio or smth like that. Then an engineer looks at the diagram and tries to implement it in bicep. So now there is a need for an Architect, to verify if whatever has been developed matched the design. Basically i is about checking whether or not all required resources are in their places, connected to correct vnets/subnets with correct private endpoints, etc. \ No newline at end of file From f431783a2c0d29c0c7c0595a52d9b26bab43c851 Mon Sep 17 00:00:00 2001 From: eosfor <9363027+eosfor@users.noreply.github.com> Date: Wed, 26 Mar 2025 16:25:49 +0000 Subject: [PATCH 2/2] another test --- scripts/psrule-demo/readme.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/psrule-demo/readme.md b/scripts/psrule-demo/readme.md index c8f604a..de6bda6 100644 --- a/scripts/psrule-demo/readme.md +++ b/scripts/psrule-demo/readme.md @@ -38,4 +38,29 @@ VERBOSE: [Invoke-PSRule] END:: But my expectation here that it should find the rule, which it does, then it should run a rule, find a resource of a type `Microsoft.Network/virtualNetworks` which is defined in [modules/network.bicep](/scripts/psrule-demo/modules/network.bicep), and return `success`. -The scenario is simple, there is an, say, Architect, who defines how a sertain solution shouls look in in Azure. Basically in most cases iti is a diagram in visio or smth like that. Then an engineer looks at the diagram and tries to implement it in bicep. So now there is a need for an Architect, to verify if whatever has been developed matched the design. Basically i is about checking whether or not all required resources are in their places, connected to correct vnets/subnets with correct private endpoints, etc. \ No newline at end of file +The scenario is simple, there is an, say, Architect, who defines how a sertain solution shouls look in in Azure. Basically in most cases iti is a diagram in visio or smth like that. Then an engineer looks at the diagram and tries to implement it in bicep. So now there is a need for an Architect, to verify if whatever has been developed matched the design. Basically i is about checking whether or not all required resources are in their places, connected to correct vnets/subnets with correct private endpoints, etc. + +> @eosfor the problem is mostly related to finding files. When running from a working path of /workspaces/scripting-notes/scripts/psrule-demo/ the arguments -Option and -Path are not required. Are you able to verify the files are found by using this. Will have a bit deeper look as well in the background. + +Here is the result of it + +```powershell +PS /workspaces/scripting-notes/scripts/psrule-demo> Invoke-PSRule -InputObject . -Verbose -Debug +``` + +results in + +```console +VERBOSE: [Invoke-PSRule] BEGIN:: +VERBOSE: [New-PSRuleOption] BEGIN:: +VERBOSE: Attempting to read: +VERBOSE: [New-PSRuleOption] END:: +VERBOSE: [PSRule][D] -- Scanning for source files: .ps-rule/ +VERBOSE: [PSRule][D] -- Discovering rules in: /workspaces/scripting-notes/scripts/psrule-demo/.ps-rule/local.ArchitectureVerification.Rule.ps1 +VERBOSE: [PSRule][D] -- Found .\local.Architecture.Verification in /workspaces/scripting-notes/scripts/psrule-demo/.ps-rule/local.ArchitectureVerification.Rule.ps1 +VERBOSE: [PSRule][R][0][.\local.Architecture.Verification] :: d606135e18f175bdf2183746f1c94efd0ea6a9e1 +DEBUG: Target failed Type precondition +VERBOSE: [Invoke-PSRule] END:: +``` + +However here I would still expect it executing the rule for a nested resource.