【问题标题】:Azure PowerShell RM Cmdlet AccountAdminLiveEmailIdAzure PowerShell RM Cmdlet AccountAdminLiveEmailId
【发布时间】:2016-05-19 15:55:00
【问题描述】:

Azure PowerShell 中是否有可返回 AccountAdminLiveEmailId 的 RM cmdlet?

如果您使用经典的 cmdlet,您可以使用:

Get-AzureSubscription -ExtendedDetails

这将返回一个包含 AccountAdminLiveEmailId 的对象。不幸的是,这是一个经典的 cmdlet,因此它需要您使用

登录
Add-AzureAccount

而 RM cmdlet 要求您使用

登录
Login-AzureRmAccount

Add-AzureRmAccount

我们不希望人们登录两次,这样我们就可以访问 RM 和经典 cmdlet,因此我们需要一个可以获取 AccountAdminLiveEmailId 的 RM cmdlet。谢谢。

更新:

使用 Jack Zeng 的答案,我想出了这个。

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)
}

【问题讨论】:

    标签: powershell azure azure-powershell


    【解决方案1】:

    您可以使用以下 PowerShell 命令获取 AccountAdminLiveEmailId。

    Get-AzureRmRoleAssignment -IncludeClassicAdministrators | where {$_.RoleDefinitionName -eq "<admin role>"}
    

    对于&lt;admin role&gt;,这取决于您的订阅设置。对于我来说,它是“ServiceAdministrator;AccountAdministrator”。它可能是“GlobalAdministrator”。

    这仍然是经典模式,即使它使用的是 ARM PowerShell。经典管理员的概念正在退休。 ARM 模式鼓励您使用基于角色的访问控制。

    【讨论】:

    • 谢谢!弄乱那个 cmdlet 让我得到了我需要的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-12
    • 2013-01-12
    • 2014-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多