您能否通过PowerShell授予Azure应用程序的管理员访问权限

您能否通过PowerShell授予Azure应用程序的管理员访问权限,azure,adal,Azure,Adal,是否有方法仅使用PowerShell授予应用程序管理许可?假设您已连接MsolService并提供了租户管理员帐户的凭据;有没有办法根据应用程序客户端ID提供租户范围的同意书?澄清一下,您的意思是授予应用程序以管理员身份访问目录的能力 如果是这种情况,您可以执行以下操作: # Using the Windows Azure Active Directory Module for Windows PowerShell # # Connect to the tenant to modify Conn

是否有方法仅使用PowerShell授予应用程序管理许可?假设您已连接MsolService并提供了租户管理员帐户的凭据;有没有办法根据应用程序客户端ID提供租户范围的同意书?

澄清一下,您的意思是授予应用程序以管理员身份访问目录的能力

如果是这种情况,您可以执行以下操作:

# Using the Windows Azure Active Directory Module for Windows PowerShell
#
# Connect to the tenant to modify
Connect-MsolService # => login

# Get Service Principal to add the role to
$servicePrincipal = Get-MsolServicePrincipal -ServicePrincipalName Principal.Name

# Get role object ID
# Alternatively, you can list all the roles (in order to get a different role name) using just `Get-MsolRole`
$roleId = (Get-MsolRole -RoleName "Directory Readers").ObjectId

# Add role to service principal
Add-MsolRoleMember -RoleObjectId $roleId -RoleMemberObjectId     $servicePrincipal.ObjectId -RoleMemberType servicePrincipal

# Check our work
Get-MsolRoleMember -RoleObjectId $roleId # => should include Principal.Name in list
从这里开始:


只有在授权过程中通过ADAL才能同意应用程序请求的权限(通过其RequiredResourceAccess)。

谢谢。不幸的是,不需要将应用程序添加到角色,需要的是对应用程序进行实际的同意,这通常是通过浏览器进行的(即,当您重定向授权代码并在查询字符串中包含prompt=admin_approve时。在这种情况下,我在PowerShell中有一个已登录的用户是租户管理员,因此我希望他们能够执行相同的操作,但显然不能在浏览器中执行。是否有某种直接发布到Graph API的方式可以解决此问题他的?