Skip to content

Commit

Permalink
Correct property reference; casing fix; skipping checks if null (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunami28 and [email protected] authored Jun 6, 2024
1 parent 7ee6fab commit ebf5837
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
32 changes: 18 additions & 14 deletions Scripts/Helpers/Confirm-PolicyResourceExclusions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
22 changes: 11 additions & 11 deletions Scripts/Operations/Export-AzPolicyResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Expand Down

0 comments on commit ebf5837

Please sign in to comment.