【发布时间】:2022-08-03 19:33:48
【问题描述】:
我创建了 PowerShell 7 Azure 函数 (AF) 和一个托管服务标识 (MSI),在整个订阅中具有读者角色。 在此处使用此代码:
Connect-AzAccount -Identity
$token = Get-AzAccessToken -ResourceUrl \"https://graph.microsoft.com\"
Connect-MgGraph -AccessToken $token.Token
当我在 (AF) 日志窗口中收到 \'Hello to Graph\' 时,通过 Graph 的连接起作用。 但是,在搜索用户时;
get-mgUser -userID \'objectID of the user\'
我收到的许可被拒绝。 使用:
connect-mgGraph -Scopes
提示进行交互式登录...
查看 MSI 的企业应用程序注册,我无法授予任何权限(以 GA 身份登录)。 有人可以指出我正确的方向吗?
-
其他用户的
get-mgUser至少需要-Scopes User.Read.All。您可以以交互方式运行一次并同意您的 MSI 权限,或按照此处的一些步骤手动授予权限:docs.microsoft.com/en-us/graph/…。您可以使用Get-MgContext检查您当前的权限/范围
标签: azure powershell graph