首页 > 解决方案 > 如何使用 PowerShell 获取为 SQL Server 分配的 Azure Active Directory 管理员?

问题描述

我想使用 PowerShell 脚本获取特定 Azure SQL 服务器当前分配的 Active Directory 管理员名称。

Azure 门户

我认为它会显示在资源属性中,但不幸的是没有,我没有找到任何特定的命令。

有什么方法可以获取这些信息吗?

标签: azurepowershellactive-directoryazure-sql-databaseazure-active-directory

解决方案


获取此信息的 PowerShell 命令是 Get-AzureRmSqlServerActiveDirectoryAdministrator

来自 Microsoft 文档的示例 -

Get-AzureRmSqlServerActiveDirectoryAdministrator -ResourceGroupName "ResourceGroup01" -ServerName "Server01"
ResourceGroupName ServerName DisplayName ObjectId 
----------------- ---------- ----------- -------- 
ResourceGroup01   Server01   DBAs        40b79501-b343-44ed-9ce7-da4c8cc7353b

https://docs.microsoft.com/en-us/powershell/module/azurerm.sql/get-azurermsqlserveractivedirectoryadministrator?view=azurermps-6.7.0

此外,至少在您的屏幕截图中,您没有为服务器设置任何管理员。如果您想先进行设置,在从 PowerShell 命令读取该信息之前,请按照此处的指导进行操作 - https://docs.microsoft.com/en-us/azure/sql-database/sql-database-aad-authentication -配置


推荐阅读