[英]Powershell: List/Export all Azure Storage Accounts with "NetworkRuleSet" property to CSV
Being a novice at Powershell, I'm trying the following:作为 Powershell 的新手,我正在尝试以下操作:
I have found the below script, which essentially does part of it, but it lacks the option to fetch for all subscriptions and the export part.我找到了下面的脚本,它基本上完成了其中的一部分,但它缺少获取所有订阅和导出部分的选项。 Any help is much appreciated.
任何帮助深表感谢。
BR, Jim BR,吉姆
$Result=@()
$Storageaccounts = Get-AzStorageAccount
$Storageaccounts | ForEach-Object {
$storageaccount = $_
Get-AzStorageAccountNetworkRuleSet -ResourceGroupName $storageaccount.ResourceGroupName -AccountName $storageaccount.StorageAccountName | ForEach-Object {
$Result += New-Object PSObject -property @{
Account = $storageaccount.StorageAccountName
ResourceGroup = $storageaccount.ResourceGroupName
Bypass = $_.Bypass
Action = $_.DefaultAction
IPrules = $_.IpRules
Vnetrules = $_.VirtualNetworkRules
ResourceRules = $_.ResourceAccessRules
}
}
}
$Result | Select Account,ResourceGroup,Bypass,Action,IPrules,Vnetrules,ResourceRules```
To export the data to CSV file change the $Result
line with below code.要将数据导出到 CSV 文件,请使用以下代码更改
$Result
行。
$Result | Select Account,ResourceGroup,Bypass,Action,IPrules,Vnetrules,ResourceRules | Export-Csv -Path C:\Users\v-vedod\Desktop\9.csv
Below code will help you in setting content to script for that particular subscription but there is no option to run all the subscriptions.下面的代码将帮助您将内容设置为该特定订阅的脚本,但没有运行所有订阅的选项。
Set-AzContext -Subscription (use your subscription id)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.