Created
November 28, 2022 17:25
-
-
Save omarmciver/a573c9882c25f75ecb6a7e33790885c4 to your computer and use it in GitHub Desktop.
Get All SQL Servers (or any resource type) #PowerShell #Azure
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
#az login | |
$subs = az account list | ConvertFrom-Json | |
$allServers = @() | |
foreach($sub in $subs){ | |
Write-Output $sub.Name | |
az account set -s $sub.Id | |
$subServers = az resource list --resource-type 'Microsoft.Sql/servers' | ConvertFrom-Json | |
foreach($server in $subServers){ | |
$allServers += $server | |
} | |
} | |
$allServers | Format-Table -Property name, kind, id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment