Created
August 29, 2016 16:45
-
-
Save brlinton/cb169c8c3f358d86292294f1d9d82ae7 to your computer and use it in GitHub Desktop.
Print out all of the resources in a subscription (starting with SQL databases)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Login-AzureRmAccount | |
$OutFilePath = "D:\sql-databases.csv" | |
ForEach ($resourceGroup in Get-AzureRmResourceGroup) | |
{ | |
ForEach ($sqlServer in Get-AzureRMSqlServer -ResourceGroupName $resourceGroup.ResourceGroupName) | |
{ | |
ForEach($sqlDatabase in Get-AzureRMSqlDatabase -ServerName $sqlServer.ServerName -ResourceGroupName $resourceGroup.ResourceGroupName) | |
{ | |
If($sqlDatabase.Name -ine "master") | |
{ | |
$sqlServer.ServerName + "," + $sqlDatabase.DatabaseName + "," + $sqlDatabase.Edition + "," + $sqlDatabase.Location + "," + $sqlDatabase.CurrentServiceObjectiveName | out-file $OutFilePath -encoding ascii -append | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment