[英]How to export LocalNetworkGateway info from multiple Resource Groups
I'm new to powershell and azure and need to export all the LocalNetworkGateway information from multiple Subscriptions and Resource Groups . 我是Powershell和Azure的新手,需要从多个订阅和资源组中导出所有LocalNetworkGateway信息。
I have a script to export from Resource Groups but I have to manually enter the ResourceGroupName for each one. 我有一个脚本可以从资源组中导出,但是我必须手动输入每个脚本的ResourceGroupName 。
Is there a way to have a variable that contains all the ResourceGroupNames so that I don't have to run the script 40 times and manually enter a different ResourceGroupName for each? 有没有一种方法可以包含一个包含所有ResourceGroupName的变量,这样我就不必运行脚本40次并为每个脚本手动输入一个不同的ResourceGroupName ?
Any help would be gratefully received. 任何帮助将不胜感激。
I have code for one Resource Group at a time. 我一次有一个资源组的代码。
Get-AzLocalNetworkGateway -ResourceGroupName “RGName” | Export-Csv -Path "c:\Azure\LocalNetworkGateway.csv"
you can just iterate over resource groups: 您可以遍历资源组:
$resourceGroups = Get-AzResourceGroup
$resourceGroups.foreach{
Get-AzLocalNetworkGateway -ResourceGroupName $_.ResourceGroupName |
Export-Csv -Path "c:\Azure\LocalNetworkGateway.csv" -Append
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.