diff --git a/Scripts/Helpers/Confirm-PolicyResourceExclusions.ps1 b/Scripts/Helpers/Confirm-PolicyResourceExclusions.ps1 index f015f0e4..7f08c5a8 100644 --- a/Scripts/Helpers/Confirm-PolicyResourceExclusions.ps1 +++ b/Scripts/Helpers/Confirm-PolicyResourceExclusions.ps1 @@ -28,25 +28,29 @@ function Confirm-PolicyResourceExclusions { } return $false, $resourceIdParts } - if ($ExcludedScopesTable.ContainsKey($scope)) { - Write-Verbose "Excluded scope '$scope', resource '$($ResourceId)'" - if ($null -ne $PolicyResourceTable) { - $PolicyResourceTable.counters.excluded += 1 - } - # if ($resourceIdParts.kind -eq "policyAssignments") { - # $excludedScope = $ExcludedScopesTable.$scope - # $null = $null - # } - return $false, $resourceIdParts - } - foreach ($testExcludedId in $ExcludedIds) { - if ($TestId -like $testExcludedId) { - Write-Verbose "Excluded id '$($ResourceId)'" + if ($null -ne $ExcludedScopesTable) { + if ($ExcludedScopesTable.ContainsKey($scope)) { + Write-Verbose "Excluded scope '$scope', resource '$($ResourceId)'" if ($null -ne $PolicyResourceTable) { $PolicyResourceTable.counters.excluded += 1 } + # if ($resourceIdParts.kind -eq "policyAssignments") { + # $excludedScope = $ExcludedScopesTable.$scope + # $null = $null + # } return $false, $resourceIdParts } } + if ($null -ne $ExcludedIds) { + foreach ($testExcludedId in $ExcludedIds) { + if ($TestId -like $testExcludedId) { + Write-Verbose "Excluded id '$($ResourceId)'" + if ($null -ne $PolicyResourceTable) { + $PolicyResourceTable.counters.excluded += 1 + } + return $false, $resourceIdParts + } + } + } return $true, $resourceIdParts } diff --git a/Scripts/Operations/Export-AzPolicyResources.ps1 b/Scripts/Operations/Export-AzPolicyResources.ps1 index ec0bce40..4891e77f 100644 --- a/Scripts/Operations/Export-AzPolicyResources.ps1 +++ b/Scripts/Operations/Export-AzPolicyResources.ps1 @@ -221,10 +221,10 @@ if ($Mode -ne 'exportFromRawFiles') { if ($Mode -eq 'psrule') { $newScopeTable = @{} foreach ($scope in $scopeTable.GetEnumerator()) { - if ($scope.Value.childrenList.ContainsKey($pacEnvironmentOriginalScope)) { + if ($scope.Value.parentTable.ContainsKey($pacEnvironmentOriginalScope)) { $newObj = $scope.Value | Select-Object -ExcludeProperty childrenList $children = @{} - $scope.Value.childrenList.GetEnumerator() | Where-Object Key -eq $pacEnvironmentOriginalScope | ForEach-Object { + $scope.Value.parentTable.GetEnumerator() | Where-Object Key -eq $pacEnvironmentOriginalScope | ForEach-Object { $children.Add($_.Key, $_.Value) } Add-Member -InputObject $newObj -MemberType NoteProperty -Name childrenList -Value $children @@ -288,18 +288,18 @@ if ($Mode -ne 'exportFromRawFiles') { Sku = $policy.Value.Sku PolicyAssignmentId = $policy.Value.ResourceId Properties = @{ - Scope = $policy.Value.Properties.Scope - NotScope = $policy.Value.Properties.NotScope - DisplayName = $policy.Value.Properties.DisplayName - Description = $policy.Value.Properties.Description - Metadata = $policy.Value.Properties.Metadata - EnforcementMode = switch ($policy.Value.Properties.EnforcementMode) { + Scope = $policy.Value.properties.scope + NotScope = $policy.Value.properties.notScopes + DisplayName = $policy.Value.properties.displayName + Description = $policy.Value.properties.description + Metadata = $policy.Value.properties.metadata + EnforcementMode = switch ($policy.Value.properties.enforcementMode) { 0 { "Default" } 1 { "DoNotEnforce" } } - PolicyDefinitionId = $policy.Value.Properties.PolicyDefinitionId - Parameters = $policy.Value.Properties.Parameters - NonComplianceMessages = $policy.Value.Properties.NonComplianceMessages + PolicyDefinitionId = $policy.Value.properties.policyDefinitionId + Parameters = $policy.Value.properties.parameters + NonComplianceMessages = $policy.Value.properties.nonComplianceMessages } }