连接每个订阅并检索resourcegroupname

时间:2017-10-17 18:30:06

标签: azure

请帮我写一个脚本来连接每个订阅来自" Get-AzureRmSubscription | ft名称"并运行Get-AzureRmOperationalInsightsWorkspace以检索分配给它的工作空间。

感谢

1 个答案:

答案 0 :(得分:0)

以下是答案:

$subs = Get-AzureRmSubscription | Select-Object SubscriptionName, SubscriptionId 
    foreach($sub in $subs)
    {
        $subName =$sub.SubscriptionName
        Set-AzureRmContext -SubscriptionName $subName | Out-Null
        Write-host "Subscription Name: " $subName
        Get-AzureRmResourceGroup | Format-Table ResourceGroupName
}