anonymous user :
You can try out the following powershell script to get the desired results:
$SubscriptionList = Get-AzSubscription
$collectionWithItems = New-Object System.Collections.ArrayList
Foreach ($subscription in $SubscriptionList)
{
Write-Host $subscription.Name
Set-AzContext -SubscriptionId $subscription.Id
$ResourceGroupList = Get-AzResourceGroup
Foreach ($ResourceGroup in $ResourceGroupList)
{
Write-Host 'Resource Id : ' $ResourceGroup.ResourceId
$exemptions= Get-AzPolicyExemption -Scope $ResourceGroup.ResourceId
$temp = New-Object System.Object
$temp | Add-Member -MemberType NoteProperty -Name "ResourceId" -Value $ResourceGroup.ResourceId
Foreach ($exemption in $exemptions)
{
Write-Host 'Exemption : ' $exemption.Name
$temp | Add-Member -MemberType NoteProperty -Name "Exemption" -Value $exemption.Name
$collectionWithItems.Add($temp)
}
}
}
$collectionWithItems | Export-Csv -Path .\ExportedData.csv -NoTypeInformation
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.