如何使用 Set-MgUserPhotoContent 设置 Microsoft Entra ID 用户照片

设置 Microsoft Entra ID 用户照片

在 Microsoft Entra ID 中添加用户照片可以更容易识别同事,提升团队合作与 Microsoft 365 应用中的协作效率。同时,它还帮助 IT 团队管理用户并增强安全性。此外,ADManager Plus 作为一款具备 Microsoft 365 管理和报告 功能的 IGA 解决方案,允许管理员通过智能模板即时设置用户照片。虽然 ADManager Plus 和 Graph PowerShell 都可用于更新用户照片,但 ADManager Plus 以其直观且无需脚本的界面脱颖而出,使管理员能够轻松批量更新和管理用户照片,无需编写脚本。其用户友好的设计消除了复杂脚本的需求,是寻求简化高效解决方案的组织的理想选择。

  • ADManager Plus
  • PowerShell
 

使用 ADManager Plus 配置 Microsoft Entra ID 用户照片

  1. 登录 ADManager Plus 并导航至 Management 选项卡。
  2. User Management 选项卡中,位于 User Templates 下,点击 > User Creation Templates
  3. 点击 +Create New Template
  4. 为模板提供名称和描述。
  5. Select Domain 字段中选择此模板应使用的域。
  6. 选中 Microsoft 365 复选框。
  7. 点击 Enable Drag-and-drop 按钮。
  8. Field TrayGeneral 部分拖放 User Photo 字段到 Microsoft 365 选项卡。
  9. Edit User Photo 弹出窗口中,输入 Field Name,选择 Photo Attribute 类型,如有需要将字段设为 Mandatory,然后点击 Done
  10. 点击 Save Template 保存此模板。
  11. 创建 Entra ID 用户时,应用此模板并上传用户照片。
使用 ADManager Plus 的智能模板设置 Microsoft Entra ID 用户照片
 
 

根据需要修改模板以添加或删除字段。

 
 

包含可轻松拖放的属性。

 
 

点击编辑图标将此字段设为必填。

使用 Microsoft Graph PowerShell 设置 Microsoft Entra ID 用户照片

前提条件

在使用 Set-MgUserPhotoContent cmdlet 之前,请确保以下事项:

  • The Microsoft Graph PowerShell module is installed. If not, install it using this script:
    Install-Module Microsoft.Graph -Scope CurrentUser
  • Connect to Microsoft Graph PowerShell with the required permissions to set Microsoft Entra ID users' photos.
    Connect-MgGraph -Scopes "User.ReadWrite.All"

使用 Set-MgUserPhotoContent 命令

Set-MgUserPhotoContent cmdlet 可用于 Microsoft Graph PowerShell 中配置 Microsoft Entra ID 用户照片。语法如下:

Set-MgUserPhotoContent
-UserId <String>
[-Data <Stream>]
[-ResponseHeadersVariable <String>]
-InFile <String>
[-ContentType <String>]
[-Headers <IDictionary>]
[-PassThru]
[-ProgressAction <ActionPreference>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

示例:上传用户照片

Set-MgUserPhotoContent -UserId user@yourdomain.com -InFile C:\Photos\userphoto.jpg

支持的参数

以下是可与 Set-MgUserPhotoContent 命令一起使用的一些重要参数:

参数 描述
-UserId 此参数用于指定要更新照片的用户的 UserPrincipalName 或对象 ID。
-InFile 此参数定义要上传的图像的本地文件路径。
-Confirm 此参数通过执行命令前提示确认,帮助防止意外更改。
-WhatIf 此参数模拟命令执行,但不实际执行。

使用 Graph PowerShell 脚本设置 Entra ID 用户照片的限制

  • Graph PowerShell 需要管理员熟悉脚本、PowerShell 命令和 Graph API 才能执行命令。
  • 大规模更新可能会被限制或暂时阻止,影响批量操作。
  • Graph PowerShell 缺乏直观界面,使照片管理不够用户友好。
  • 没有内置的上传状态指示器,难以跟踪成功或失败。

使用 ADManager Plus 设置 Microsoft Entra ID 用户照片的优势

  • 提供直观界面,便于照片管理,无需 PowerShell 脚本。
  • 照片可通过几次点击上传,减少手动操作。
  • 上传后提供状态更新,而 Graph PowerShell 需要额外参数。

除了管理用户外,ADManager Plus 还提供对各种 Microsoft Entra ID(前称 Azure AD)实体的全面管理功能,包括 联系人邮箱。它还提供了丰富的 Micrsosft Entra ID 报告,为 Entra ID 对象和活动提供有价值的洞察。这些报告帮助管理员跟踪 用户登录组成员资格不活跃账户许可证分配 等信息。

使用 ADManager Plus 上传 Entra ID 用户照片

 
  • 设置 Microsoft Entra ID 用户照片
  • 使用 ADManager Plus 配置 Microsoft Entra ID 用户照片
  • 使用 Microsoft Graph PowerShell 设置 Microsoft Entra ID 用户照片
  • 使用 Graph PowerShell 脚本管理 Microsoft Entra ID 用户的限制
  • 使用 ADManager Plus 管理 Microsoft Entra ID 用户的亮点
Active Directory管理与报告的一站式解决方案
电子邮件下载链接 Email the ADManager Plus download link