简体   繁体   English

Powershell:列出/导出所有具有“NetworkRuleSet”属性的 Azure 存储帐户到 CSV

[英]Powershell: List/Export all Azure Storage Accounts with "NetworkRuleSet" property to CSV

Being a novice at Powershell, I'm trying the following:作为 Powershell 的新手,我正在尝试以下操作:

  • Fetch all storage accounts from all subscriptions in Azure从 Azure 中的所有订阅中获取所有存储帐户
  • List the "NetworkRuleSet" property (I want to check which.networks the account belongs to and if they have "All".networks checked)列出“NetworkRuleSet”属性(我想检查该帐户属于哪个网络,以及是否检查了“全部”网络)

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.

相关问题 使用 powershell 查找/列出 azure 中未使用的存储帐户 - Find/list the Unused storage accounts in azure using powershell 将 CSV 从 Azure Automation 导出到 Microsoft Teams 而不是 blob 存储? - Export a CSV from Azure Automation to Microsoft Teams instead of blob storage? PowerShell Azure Function:列出存储 A/c blob = 未经授权 - PowerShell Azure Function: list Storage A/c blobs = unauthorised 导出所有 Azure AD 组,包括嵌套组、它们的成员和所有者 (PowerShell) - Export all Azure AD groups, including nested groups, their members and owners (PowerShell) 作为 Azure 存储帐户的诊断设置启用的一部分,应启用哪些所有日志/指标 - What all logs/Metrics should be enabled as part of the Diagnostic settings enablement for Azure Storage Accounts 在 aws orgazination 中,使用分页列出所有帐户 - in aws orgazination, use paginate to list all accounts 无法将 csv 文件上传到 azure 存储 blob - Not able to uploading csv file to azure storage blob Output Azure Function powershell值到azure存储账户 - Output Azure Function powershell value to azure storage account Azure AzCopy 命令无法将 csv 文件复制到 Azure 存储 - Azure AzCopy command fail to copy csv files to Azure Storage 如何使用 for_each 或 count for azure 为多个名称创建具有存储帐户的多个资源组? - How to create multiple resource groups with storage accounts for multiple names using for_each or count for azure?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM