当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何查找 Graph PowerShell 命令权限

作者:精品下载站 日期:2024-12-14 13:37:10 浏览:16 分类:玩电脑

如何查找 Graph PowerShell 命令权限


[玩转系统] 如何查找 Graph PowerShell 命令权限

使用 Microsoft Graph PowerShell SDK,您需要使用范围连接到 Graph API。

范围表示在会话期间执行命令所需的权限。

但是您需要什么权限?

识别这一点的最简单方法是使用 Find-MgGraphCommand CmdLet。

例如,要确定运行 Get-MgUser 所需的权限,请运行以下命令:

Find-MgGraphCommand -Command Get-MgUser -ApiVersion v1.0

重要参数有:

  • 命令(强制)
  • ApiVersion(在 v1.0 和 Beta 之间选择)

输出将类似于以下内容:

PS C:\> Find-MgGraphCommand -Command Get-MgUser -ApiVersion v1.0


   APIVersion: v1.0

Command    Module Method URI              OutputType           Permissions                                                                                                                                                   Variants
-------    ------ ------ ---              ----------           -----------                                                                                                                                                   --------
Get-MgUser Users  GET    /users/{user-id} IMicrosoftGraphUser1 {DeviceManagementApps.Read.All, DeviceManagementApps.ReadWrite.All, DeviceManagementManagedDevices.Read.All, DeviceManagementManagedDevices.ReadWrite.All...} {Get1, GetViaIdentity1}
Get-MgUser Users  GET    /users           IMicrosoftGraphUser1 {DeviceManagementApps.Read.All, DeviceManagementApps.ReadWrite.All, DeviceManagementManagedDevices.Read.All, DeviceManagementManagedDevices.ReadWrite.All...} {List1}

这两行表示针对特定用户的请求和针对用户的一般请求。

要更详细地查看一般请求所需的权限,请运行以下命令:

(Find-MgGraphCommand -Command Get-MgUser -ApiVersion v1.0 | ? { $_.URI -eq '/users'}).Permissions | ft Name,Description

这将生成类似于以下内容的输出:

PS C:\> (Find-MgGraphCommand -Command Get-MgUser -ApiVersion v1.0 | ? { $_.URI -eq '/users'}).Permissions | ft Name,Description

Name                                         Description
----                                         -----------
DeviceManagementApps.Read.All                Read Microsoft Intune apps
DeviceManagementApps.ReadWrite.All           Read and write Microsoft Intune apps
DeviceManagementManagedDevices.Read.All      Read devices Microsoft Intune devices
DeviceManagementManagedDevices.ReadWrite.All Read and write Microsoft Intune devices
DeviceManagementServiceConfig.Read.All       Read Microsoft Intune configuration
DeviceManagementServiceConfig.ReadWrite.All  Read and write Microsoft Intune configuration
Directory.AccessAsUser.All                   Access the directory as you
Directory.Read.All                           Read directory data
Directory.ReadWrite.All                      Read and write directory data
User.Read.All                                Read all users' full profiles
User.ReadBasic.All                           Read all users' basic profiles
User.ReadWrite.All                           Read and write all users' full profiles

您将注意到,除了用户和目录权限之外,权限还包括各种 Intune 权限。

使用 Get-MgUser 命令查询标准用户时,您可能不需要这些权限。

此外,某些列出的权限是您可以跳过的子集(例如,Directory.ReadWrite.All 包括 Directory.Read.All)。

轻松的 Office 365 管理

如果您想使用 Microsoft Graph PowerShell API 管理 Office 365 环境而无需编写任何代码,请查看 Easy365Manager。

Easy365Manager 是 AD 用户和计算机的管理单元,为您提供用户友好且快速的 Office 365 管理:

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯