question

alirazeghi-1315 avatar image
0 Votes"
alirazeghi-1315 asked learn2skills answered

Get-AZSqlServer requires ServerName which is unknown

I am trying to use powershell to look for all database servers inside a resource group. I don't have the server name to pass in, I want to query for it but get-azsqlserver isn't working unless I pass in the servername.

If I run get-azsqlserver without a server name none of my SQL Servers come up. If I specify the server name, it comes up. ( Examples 1 and 2 in the picture)

If I pass in the ResourceID found from get-azsqlserver into get-azresource, it comes up fine. If I don't pass it in, it doesn't come up at all.

Could anyone show me a link or steps to query all database servers within a resource group?80806-untitled.png


windows-server-powershellazure-sql-database
untitled.png (78.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

learn2skills avatar image
0 Votes"
learn2skills answered

Hi @alirazeghi-1315
Thank you for posting in Q & A.

Below URL shows steps to query all database servers within a resource group.
API call - Servers - List By Resource Group
https://docs.microsoft.com/en-us/rest/api/sql/servers/listbyresourcegroup

How to list all databases in Azure CLI
https://stackoverflow.com/questions/47452890/how-to-list-all-databases-in-azure-cli

Get all instances of SQL Server assigned to a resource group
https://docs.microsoft.com/en-us/powershell/module/az.sql/get-azsqlserver?view=azps-5.7.0


If the Answer is helpful, please click Accept Answer and up-vote, this can be beneficial to other community members.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.