Get-AZSqlServer requires ServerName which is unknown

ali razeghi 21 Reputation points
2021-03-23T23:42:23.897+00:00

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

Azure SQL Database
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

Accepted answer
  1. SUNOJ KUMAR YELURU 13,946 Reputation points MVP
    2021-03-24T01:14:34.557+00:00

    Hi @ali razeghi
    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://learn.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://learn.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.

    0 comments No comments

0 additional answers

Sort by: Most helpful