Azure Powershell-跨EA中的多个订阅 [英] Azure Powershell - across MULTIPLE subscriptions in an EA

查看:100
本文介绍了Azure Powershell-跨EA中的多个订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在EA中开帐单的读者访问数百个订阅。



我正在尝试获取所有订阅中虚拟机及其大小的列表。



因此,当前,当我运行 Get-AzureRMSubscription时,它会向我显示所有的订阅(其中有数百个),但是我不确定如何实际运行



在所有订阅中都获得一个 Get-AzureRMVM真是太好了



有什么建议么?
预先感谢!

解决方案

您可以执行以下操作:

  $ azureSubs = Get-AzureRMSubscription 
$ azureSubs | ForEach-Object {Select-AzureRMSubscription $ _ |空无; Get-AzureRMVM -WarningAction SilentlyContinue}

您实际上是在设置一个数组变量来保存所有Azure订阅和将其通过管道传递到ForEach-Object cmdlet,以迭代数组中的所有对象。然后,将其通过管道传递到Get-AzureRMVM cmdlet,以列出每个订阅中的所有VM。至少您可以运行它而忘记它。



出现Out-Null和-WarningAction的原因是抑制不需要的输出。


I have "billing reader" access to several hundred subscriptions in an EA.

I'm trying to get a list of virtual machines and their sizes across all subscriptions.

So currently when I run a "Get-AzureRMSubscription" it shows me all the subscriptions (hundreds of them), but i'm not sure how to actually run a script against all the subscriptions?

Would be great to get a "Get-AzureRMVM" across them all

Any suggestions? Thanks in advance!

解决方案

You can possibly do something like this:

$azureSubs = Get-AzureRMSubscription
$azureSubs | ForEach-Object {Select-AzureRMSubscription $_ | Out-Null; Get-AzureRMVM -WarningAction SilentlyContinue}

You are essentially setting an array variable to hold all your Azure Subscription and piping it to the ForEach-Object cmdlet to iterate all of the objects in the array. Then you pipe it to the Get-AzureRMVM cmdlet to list all VMs in each subscription.

This is definitely not optimized for performance and there might be better solutions out there, but at least you can run it and forget it.

The reason for the Out-Null and -WarningAction is to suppress the outputs you do not need.

这篇关于Azure Powershell-跨EA中的多个订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆