I wrote the below powershell script to get all Azure policy assignment within an azure subscription but when I try to export the result using Export-CSV
, I get a System.String[]
error for the NotScope row.
Get-AzResourceGroup | Select-Object ResourceGroupName
ForEach-Object { (Get-AzPolicyAssignment).Properties | ForEach-Object {
$mgId += [PSCustomObject]@{
SubscriptionId = $SubscriptionId
SubscriptionName = $subscriptionName
ResourceGroupName = $resourceGroupName
PolicyName = $_.Name
DisplayName = $_.DisplayName
Scope = $_.Scope
NotScope = $_.NotScopes
}
}
}
$mgId | Export-CSV
Anyone know what I'm missing/