Skip to content

Commit

Permalink
Merge pull request #586 from Azure/585-error-when-retrieving-assignme…
Browse files Browse the repository at this point in the history
…nts-if-an-assignment-has-a-uami

585 error when retrieving assignments if an assignment has a uami
  • Loading branch information
gregslack78 authored Apr 24, 2024
2 parents 7092b09 + 45318e3 commit 8134a9a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
12 changes: 4 additions & 8 deletions Scripts/Helpers/Build-AssignmentDefinitionAtLeaf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Build-AssignmentDefinitionAtLeaf {
$nonComplianceMessages = $AssignmentDefinition.nonComplianceMessages
$hasPolicySets = $AssignmentDefinition.hasPolicySets
$perEntryNonComplianceMessages = $AssignmentDefinition.perEntryNonComplianceMessages

$flatPolicyList = $AssignmentDefinition.flatPolicyList
$thisPacOwnerId = $PacEnvironment.pacOwnerId

#endregion cache frequently used fields
Expand Down Expand Up @@ -516,10 +516,6 @@ function Build-AssignmentDefinitionAtLeaf {

$parameterObject = $null
$parametersInPolicyDefinition = @{}
if ($displayName -eq "Allowed Locations") {
$null = $null
}

if ($isPolicySet) {
$parametersInPolicyDefinition = $policySetDetails.parameters
if ($useCsv) {
Expand Down Expand Up @@ -591,9 +587,9 @@ function Build-AssignmentDefinitionAtLeaf {
if ($RoleDefinitions.ContainsKey($roleDefinitionId)) {
$roleDisplayName = $RoleDefinitions.$roleDefinitionId
}
else {
$null = $null
}
# else {
# $null = $null
# }
$requiredRoleAssignment = @{
scope = $scopeEntry.scope
roleDefinitionId = $roleDefinitionId
Expand Down
8 changes: 4 additions & 4 deletions Scripts/Helpers/Confirm-PolicyResourceExclusions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ function Confirm-PolicyResourceExclusions {
if ($null -ne $PolicyResourceTable) {
$PolicyResourceTable.counters.excluded += 1
}
if ($resourceIdParts.kind -eq "policyAssignments") {
$excludedScope = $ExcludedScopesTable.$scope
$null = $null
}
# if ($resourceIdParts.kind -eq "policyAssignments") {
# $excludedScope = $ExcludedScopesTable.$scope
# $null = $null
# }
return $false, $resourceIdParts
}
foreach ($testExcludedId in $ExcludedIds) {
Expand Down
3 changes: 1 addition & 2 deletions Scripts/Helpers/Get-AzPolicyAssignments.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ function Get-AzPolicyAssignments {
$principalId = $policyResource.identity.principalId
}
else {
$userAssignedIdentityId = $policyResource.identity.userAssignedIdentities.PSObject.Properties.Name
$principalId = $policyResource.identity.userAssignedIdentities.$userAssignedIdentityId.principalId
$principalId = $policyResource.identity.userAssignedIdentities.Values.principalId
}
$uniquePrincipalIds[$principalId] = $true
$policyResourcesTable.counters.withIdentity += 1
Expand Down

0 comments on commit 8134a9a

Please sign in to comment.