【问题标题】:Microsoft Graph PowerShell access permissions - 401 UnauthorizedMicrosoft Graph PowerShell 访问权限 - 401 Unauthorized
【发布时间】:2019-10-29 08:23:44
【问题描述】:

我正在使用Microsoft PowerShell Intune cmdlets 来查询配置设置以进行审计。尽管使用 AdminConsent 授予应用程序访问权限,但我无法连接没有管理员访问权限的帐户。我还明确地将我的用户添加到应用程序中,并且可以看到已授予“委托”访问权限。

我已使用管理员帐户成功连接到我的 Azure 环境:

Connect-MSGraph -AdminConsent
Get-DeviceManagement_DeviceCompliancePolicies

使用不是全局管理员的另一个帐户运行此操作时,我收到错误:

Get-DeviceManagement_DeviceCompliancePolicies : 401 Unauthorized
{
  "error": {
    "code": "UnknownError",
    "message": "{\"ErrorCode\":\"Forbidden\",\"Message\":\"{\\r\\n \\\"_version\\\": 3,\\r\\n  \\\"Message\\\": 
\\\"An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: 6407b0fa-a2fd-4564-8895-cc63b49e2201 

但是,我可以看到,我的用户具有预期的委托访问权限,包括:

| Microsoft Graph                | Delegated | Perform user-impacting remote actions on Microsoft Intune devices |
| ------------------------------ | --------- | ----------------------------------------------------------------- |
| Microsoft Graph                | Delegated | Read and write Microsoft Intune devices                           |
| Microsoft Graph                | Delegated | Read and write Microsoft Intune RBAC settings                     |
| Microsoft Graph                | Delegated | Read and write Microsoft Intune apps                              |
| Microsoft Graph                | Delegated | Read and write Microsoft Intune Device Configuration and Policies |
| Microsoft Graph                | Delegated | Read and write Microsoft Intune configuration                     |
| Microsoft Graph                | Delegated | Read and write all groups                                         |
| Microsoft Graph                | Delegated | Read directory data                                               |
| Microsoft Graph                | Delegated | Sign users in                                                     |
| Windows Azure Active Directory | Delegated | Sign in and read user profile                                     |
| Windows Azure Active Directory | Delegated | Read all groups                                                   |

documentation 没有什么帮助,尽管引用了我遇到的特定错误(“您的租户凭据支持管理功能。”)。目前还不清楚是否可以使用只读帐户来收集数据。

【问题讨论】:

  • 每个租户只能调用Connect-MSGraph -AdminConsent一次。要调用 API,您应该使用 Connect-MSGraph(即不使用 AdminConsent)。
  • @MarcLaFleur - 谢谢 - 明确地说,我确实在管理员同意的情况下运行过一次(为了允许应用程序),随后的调用在没有这个的情况下运行 - 不幸的是,这并不能解决我的问题尽管。我怀疑这实际上可能是我对 Azure Intune 的访问权限的其他地方的问题 - 但很难看到指定访问权限的位置
  • 请记住,您不能通过 Graph 授予比用户自己可以做的更广泛的权限。因此,如果您的用户无法管理 Intune,它也将无法使用 Graph/PowerShell 来执行此操作。

标签: powershell microsoft-graph-api


【解决方案1】:

事实证明我没有足够的耐心 - 权限“启动”需要 24 小时。

【讨论】:

    【解决方案2】:

    我们遇到了这个问题,时间延迟不是问题。

    在我们的案例中,根本原因是我们使用的服务帐户(用户对象)未在 Azure AD 中授予“Intune 管理员”角色,这是此处提到的先决条件:https://docs.microsoft.com/en-us/samples/microsoftgraph/powershell-intune-samples/intune-graph-samples/

    添加该角色后,我们的 Intune cmdlet 立即开始工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多