I have the following command that grabs a list of storage accounts and run the following command against them:
foreach($storage in Get-Content .\storageaccount.txt) {
Write-Host $storage
az storage logging show --account-name $storage
}
If I want to run this command:
az storage account management-policy show --account-name "StorageAccountName" --resource-group "RGName"
How do I grab the Resource Group associated with that Storage Account and plug it into a variable?
How do I construct the for each loop to loop through the Storage Account and the Resource Groups?
Update
Ok, so you will need to take some initiative here, look at the PowerShell Modules provided to see what you can come up with to pull it out. I don't know how your data is stored or what you can query on, but it appears you can do wild card names, locations, and tags from the PowerShell Module for Azure Storage Get-AzResourceGroups. If that doesn't work, then try looking through the documentation for something that will work.
Old Reply with Invalid code
Is there a reason you don't want to use the [PowerShell module for Azure Storage][2]?Using the module it would return an object (vs parsing text) and your code would be something like: