Forum Discussion
James_Daniel
May 14, 2024Copper Contributor
Azure subscription owners
Hi Is there any script (Azure CLI) to get the list of owners of Azure subscription. We have a around 500 subscription. we need to get a owners of each subscription. I've searched in Google but ha...
Kidd_Ip
May 16, 2024MVP
Try this:
Connect-AzAccount
$sublist= Get-AzSubscription
foreach ($item in $sublist){
$scopeappend= "/subscriptions/"+$item.Id
$export=(Get-AzRoleAssignment -RoleDefinitionId "8e3af657-a8ff-443c-a75c-2fe8c4bcb635" -Scope $tdt | where {($_.ObjectType -EQ "user") -and ($_.Scope -EQ $scopeappend) } ) | select DisplayName,SignInName
}
$export|Export-Csv -Path C:\result.csv