下午好
我为这个问题选择了stackoverflow,因为大概主要是程序员都面临这个问题:
如果调用Get-AzADUser
以在Azure自动化运行手册中获取所有AAD用户,则我们将获得:Error 'Insufficient privileges'
# Connect to AAD
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
$account = Connect-AzAccount -ServicePrincipal `
-TenantId $Conn.TenantID `
-ApplicationId $Conn.ApplicationID `
-CertificateThumbprint $Conn.CertificateThumbprint
# Get All AAD Users
$AllADUsers = Get-AzADUser
> Get-AzADUser : Insufficient privileges to complete the operation.
> FullyQualifiedErrorId :
> Microsoft.Azure.Commands.ActiveDirectory.GetAzureADUserCommand
Automation Account
设置了Run as accounts
»Azure Run As Account
(而不是Azure经典运行方式帐户)Azure Run As Account
具有误导性,它是已注册的应用程序,可以在Azure App registrations
中找到»具有all权限的自定义角色。
»API权限:
Microsoft Graph (6)
Delegated Directory.AccessAsUser.All
Delegated Directory.ReadWrite.All
Delegated User.ReadWrite.All
Application Directory.ReadWrite.All
Application User.Export.All
Application User.ReadWrite.All
»所有API权限均已授予我们的租户
不幸的是,我们仍然收到错误“权限不足”
非常感谢您的帮助!
亲切的问候,托马斯