Multiple Subscriptions #41
Closed
simon-metcalf-cubic
started this conversation in
Ideas
Replies: 2 comments 3 replies
-
Thanks for sharing! I think this adds the header in the csv multiple times. Would an optional parameter skipHeader be useful here? Setting it to true when it is not the first iteration? |
Beta Was this translation helpful? Give feedback.
3 replies
-
I added the solution to iterate over multiple subscriptions to the readme file. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I needed to pull data for over 100 subscriptions so did a quick PowerShell script to loop through, this may be useful for others.
#Connect to Azure
Connect-AzAccount -Tenant xxxxx-xxxxx-xxxxx-xxxxx
#Pull list of subscriptions
$ids = Get-AzSubscription -TenantId xxxxx-xxxxx-xxxxx-xxxxx | Select-Object id,name
#Loop through each subscription and create single CSV
$output = azure-cost costByResource -s $ ($id.id) -t Custom --from 2023-05-01 --to 2023-05-31 -o csv
Foreach ($id in $ids) {
Add-Content ".\report.csv" $output
}
Beta Was this translation helpful? Give feedback.
All reactions