Get login from Azure SQL database server (PaaS)

Dave Gray 581 Reputation points
2021-03-07T10:39:44.173+00:00

Hello I'm trying to get the security/login names from an Azure SQL database. I would have thought the login details would be held at the instance name not the database so I have used Get-AzureRmSqlServer, however I also tried Get-AzureRmSqlDatabase but cannot see how to get this below. There are six logins and I would like to retrieve their names

75104-image-396.png

Code is reduced to a single -ServerName for this question. My PowerShell code:

$Databases = Get-AzureRmSqlDatabase -ResourceGroupName "*********" -ServerName "**********"

foreach ($db in $Databases)
{
# Write-Host $db.DatabaseName
}

$sql = Get-AzureRmSqlServer -ResourceGroupName "********" -ServerName "*******"
Write-Host $sql.ServerName

Azure SQL Database
{count} votes

Accepted answer
  1. Vaibhav Chaudhari 38,681 Reputation points
    2021-03-07T14:56:11.083+00:00

    The login details are stored in Master DB. I think you will have to query sys tables by connecting to Master DB as shown in below

    https://stackoverflow.com/questions/36653699/sql-azure-list-all-logins-and-users/47470806

    Get-AzSqlServer PS Command won't list the all the login details AFAIK

    https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.commands.sql.server.model.azuresqlservermodel?view=azurerm-ps

    ----------

    Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful