Is there an RM cmdlet in Azure PowerShell that will return the AccountAdminLiveEmailId?
If you use the classic cmdlets you can use:
Get-AzureSubscription -ExtendedDetails
and this will return an object that includes the AccountAdminLiveEmailId. Unfortunately this is a classic cmdlet so it requires you to login with
Add-AzureAccount
while the RM cmdlets require you to login with
Login-AzureRmAccount
or
Add-AzureRmAccount
We don't want to have people logging in twice so we would be able to access RM and classic cmdlets so we need an RM cmdlet that will get the AccountAdminLiveEmailId. Thank you.
Update:
Using the answer from Jack Zeng I was able to come up with this.
Login-AzureRmAccount
$Subscriptions = Get-AzureRmSubscription
$Emails = New-Object System.Collections.ArrayList
foreach($Subscription in $Subscriptions)
{
Set-AzureRmContext -TenantId $Subscription.TenantId -SubscriptionId $Subscription.SubscriptionId
$Email = Get-AzureRmRoleAssignment -IncludeClassicAdministrators | where {$_.RoleDefinitionName -eq "ServiceAdministrator;AccountAdministrator"} | Select DisplayName
$Emails.Add($Email)
}