Closed anwather closed 3 months ago
Ran a debug on the code, and userAssignedIdentities is a hashtable, but gets treated as a PSCustomObject.
In Export-AzPolicyResources on 698:
if ($identityType -eq "UserAssigned") {
$userAssignedIdentities = $policyAssignment.identity.userAssignedIdentities
$identityProperty = $userAssignedIdentities.psobject.Properties
$identity = $identityProperty.Name
$identityEntry = @{
userAssigned = $identity
location = $location
}
}
Adding following code fixes export:
if ($identityType -eq "UserAssigned") {
$userAssignedIdentities = $policyAssignment.identity.userAssignedIdentities
# $identityProperty = $userAssignedIdentities.psobject.Properties
$identity = $userAssignedIdentities.GetEnumerator().Name
if($identity.Count -gt 1) {
$identityEntry = $identity | ForEach-Object {
@{
userAssigned = $PSItem
location = $location
}
}
}
else {
$identityEntry = @{
userAssigned = $identity
location = $location
}
}
}
@mortenlerudjordet - thanks works great - should release tomorrow.
Describe the bug User assigned managed identities are incorrectly being output during Export-AzPolicyResources