I have dozen of subscriptions and its very difficult to output all role assignments from all resources from all subscriptions at once. I'm currently using the one below but the output is looped for each subscription per csv file. How do I get output into one sheet preferably?
Get-AzSubscription | foreach-object {
Write-Verbose -Message "Changing to Subscription $($_.Name)" -Verbose
Set-AzContext -TenantId $_.TenantId -SubscriptionId $_.Id -Force
$Name = $_.Name
$TenantId = $_.TenantId
$SubId = $_.SubscriptionId
Get-AzRoleAssignment -IncludeClassicAdministrators | Select-Object RoleDefinitionName,DisplayName,SignInName,ObjectType,Scope,
@{name="TenantId";expression = {$TenantId}},@{name="SubscriptionName";expression = {$Name}},@{name="SubscriptionId";expression = {$SubId}} -OutVariable ra
# Also export the individual subscriptions to excel documents on your Desktop.
# One file per subscription
$ra | Export-Csv -Path C:\scripts\Export-AzRoleAssignment\$Name.csv -NoTypeInformation
}