更改用户个人资料照片
查看 YouTube 上的 Microsoft 365 小型企业帮助。
本文介绍如何管理用户帐户和Microsoft 365 组上的个人资料照片。
提示
如果需要本文中步骤的帮助,请考虑 与 Microsoft 小型企业专家合作。 借助业务助手,你和你的员工在发展业务时,可以针对从加入到日常使用的各个方面随时访问小型企业专家。
准备工作
必须是 全局管理员 才能完成这些步骤。
无法使用Microsoft 365 管理中心删除现有用户照片。 只能使用 Microsoft Graph PowerShell。
无法使用 Microsoft 365 管理中心管理Microsoft 365 组的用户照片。 只能使用 Microsoft Graph PowerShell。
照片支持的最大大小为 4 MB。
使用Microsoft 365 管理中心更改用户的个人资料照片
在Microsoft 365 管理中心中,转到“用户>活动用户”页。
在“活动用户”页上,单击行中除“检查”框以外的任意位置,选择该用户。 在打开的详细信息浮出控件中,选择“ 更改照片 ”下的现有照片占位符或浮出控件顶部的照片。
在打开的 “更改照片 ”浮出控件中,选择“ 选择照片”。
在打开 的“文件上传 ”对话框中,找到并选择照片,然后选择“ 打开”。
返回“ 更改照片 ”浮出控件,选择“ 保存更改”,然后选择“ 返回 ”返回到详细信息浮出控件,或 “关闭” 以返回到 “活动用户 ”页
提示
在用户详细信息浮出控件或 “更改照片 ”浮出控件中,可以通过右键单击照片并选择“ 将图像另存为”来下载现有照片。
在 Microsoft Graph PowerShell 中管理用户照片
安装 Microsoft Graph PowerShell SDK 后,使用 Connect-MgGraph cmdlet 使用所需的范围登录。 你需要使用管理员帐户登录才能同意所需的范围。
仅限用户:
Connect-MgGraph -Scopes "User.ReadWrite.All"
仅Microsoft 365 组:
Connect-MgGraph -Scopes "Group.ReadWrite.All"
用户和 Microsoft 365 组:
Connect-MgGraph -Scopes "User.ReadWrite.All","Group.ReadWrite.All"
在 Microsoft Graph PowerShell 中添加用户照片
用户:
Set-MgUserPhotoContent -UserId <UPN> -InFile "<PhotoPathAndFileName>"
例如:
Set-MgUserPhotoContent -UserId albertas@contoso.onmicrosoft.com -InFile "C:\Upload\Alberta Sanchez.png"
有关详细语法和参数信息,请参阅 Set-MgUserPhotoContent。
Microsoft 365 组:
Set-MgGroupPhotoContent -GroupId <ID> -InFile "<PhotoPathAndFileName>"
可以从 Get-MgGroup 命令的输出获取 Microsoft 365 组的 ID GUID 值。
例如:
Set-MgGroupPhotoContent -GroupId 173cd812-5563-439c-9da4-bc2715fa2aee -InFile "C:\Upload\Sales Department.png"
有关详细语法和参数信息,请参阅 Set-MgGroupPhotoContent。
在 Microsoft Graph PowerShell 中获取有关用户照片的信息
命令返回有关现有照片的以下信息:
- ID:值为 Default。
- 高度:以像素为单位。
- 宽度:以像素为单位。
如果用户没有照片,则命令将返回错误: Exception of type 'Microsoft.Fast.Profile.Core.Exception.ImageNotFoundException' was thrown.
。
用户:
Get-MgUserPhoto -UserId <UPN>
例如:
Get-MgUserPhoto -UserId albertas@contoso.onmicrosoft.com
有关详细语法和参数信息,请参阅 Get-MgUserPhoto。
Microsoft 365 组:
Get-MgGroupPhoto -GroupId <ID>
可以从 Get-MgGroup 命令的输出获取 Microsoft 365 组的 ID GUID 值。
例如:
Get-MgGroupPhoto -GroupId 173cd812-5563-439c-9da4-bc2715fa2aee
有关详细的语法和参数信息,请参阅 Get-MgGroupPhoto。
在 Microsoft Graph PowerShell 中下载用户照片
用户:
Get-MgUserPhotoContent -UserId <UPN> -OutFile "<PhotoPathAndFileName>
例如:
Get-MgUserPhotoContent -UserId albertas@contoso.onmicrosoft.com -OutFile "C:\Download\Alberta Sanchez.png"
有关详细语法和参数信息,请参阅 Get-MgUserPhotoContent。
Microsoft 365 组:
Get-MgGroupPhotoContent -GroupId <ID> -OutFile "<PhotoPathAndFileName>
可以从 Get-MgGroup 命令的输出获取 Microsoft 365 组的 ID GUID 值。
例如:
Get-MgGroupPhotoContent -GroupId 173cd812-5563-439c-9da4-bc2715fa2aee -OutFile "C:\Download\Sales Department.png"
有关详细语法和参数信息,请参阅 Get-MgGroupPhotoContent。
在 Microsoft Graph PowerShell 中删除用户照片
用户:
Remove-MgUserPhoto -UserId <UPN>
例如:
Remove-MgUserPhoto -UserId albertas@contoso.onmicrosoft.com
有关详细语法和参数信息,请参阅 Remove-MgUserPhoto。
Microsoft 365 组:
Remove-MgGroupPhoto -GroupId <ID>
可以从 Get-MgGroup 命令的输出获取 Microsoft 365 组的 ID GUID 值。
例如:
Remove-MgGroupPhoto -GroupId 173cd812-5563-439c-9da4-bc2715fa2aee
有关详细语法和参数信息,请参阅 Remove-MgGroupPhoto。
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈