从哪里获取 Powershell Cmdlet Remove-UserPhoto
Where Do I Get the Powershell Cmdlet Remove-UserPhoto
我在网络上的任何地方都找不到这个,我需要一个答案,这样我就可以从我们的 Azure AD 帐户的配置文件中删除所有用户照片。 Microsoft 非常友好地记录了如何使用 Get-UserPhoto and Remove-UserPhoto,但没有解释如何实际获取 Cmdlet。
我曾访问过他们的 connecting to Azure Active Directory in Powershell 文档页面,但这也无济于事。它允许我下载 AzureAD 模块(认为我需要它来 运行 那些 Cmdlet),但没有成功。谁能告诉我如何才能获得包含这些命令的模块?
更新问题:
我们只使用 Office 365。我们没有任何现场 Exchange 服务器,那么没有它我应该如何执行 Exchange PowerShell 脚本呢?任何管理员将如何做到这一点?我很难相信我是唯一一个需要从 Office 365 的配置文件中删除照片并希望以自动化方式执行此操作的白痴。
我看到的另一个问题是,当我浏览到我们的用户列表时,照片没有出现在 Azure 的用户列表中。但是,如果我随机访问 O365 应用程序(例如 Teams),则会显示个人资料图片。
获取照片:
$user = Get-ADUser "UserName" -Properties thumbnailPhoto
$user.thumbnailPhoto | Set-Content "C:\folder\photo.jpg" -Encoding byte
设置照片:
$photo = [byte[]](Get-Content "C:\folder\photo.jpg" -Encoding byte)
Set-ADUser "UserName" -Replace @{thumbnailPhoto=$photo}
删除照片:
Set-ADUser "UserName" -Clear thumbnailphoto
您需要连接到远程 Exchange Online 会话:
$credential = Get-Credential
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $exchangeSession
一旦这样做,您将导入包含 Remove-UserPhoto
cmdlet 的模块,并且能够执行您想要的操作。
运行 PowerShell ISE 作为管理员。请确保您使用的帐户具有管理权限。
粘贴到顶部并点击播放按钮:
$credential = Get-Credential
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection Import-PSSession $exchangeSession
出现提示时,使用完整的电子邮件地址登录您的 Office 帐户:rsmith@xyz.org
:
PS C:>Set-UserPhoto -Identity "rsmith" -PictureData ([System.IO.File]::ReadAllBytes("C:\rsmith.jpg")) -Confirm:$false
或:
PS C:>Set-UserPhoto -Identity "Ryan L. Smith" -PictureData ([System.IO.File]::ReadAllBytes("C:\rsmith.jpg")) -Confirm:$false
确保此帐户是 Office 管理员帐户。
请注意,-Confirm:$false
是可选的。
我在网络上的任何地方都找不到这个,我需要一个答案,这样我就可以从我们的 Azure AD 帐户的配置文件中删除所有用户照片。 Microsoft 非常友好地记录了如何使用 Get-UserPhoto and Remove-UserPhoto,但没有解释如何实际获取 Cmdlet。
我曾访问过他们的 connecting to Azure Active Directory in Powershell 文档页面,但这也无济于事。它允许我下载 AzureAD 模块(认为我需要它来 运行 那些 Cmdlet),但没有成功。谁能告诉我如何才能获得包含这些命令的模块?
更新问题: 我们只使用 Office 365。我们没有任何现场 Exchange 服务器,那么没有它我应该如何执行 Exchange PowerShell 脚本呢?任何管理员将如何做到这一点?我很难相信我是唯一一个需要从 Office 365 的配置文件中删除照片并希望以自动化方式执行此操作的白痴。
我看到的另一个问题是,当我浏览到我们的用户列表时,照片没有出现在 Azure 的用户列表中。但是,如果我随机访问 O365 应用程序(例如 Teams),则会显示个人资料图片。
获取照片:
$user = Get-ADUser "UserName" -Properties thumbnailPhoto
$user.thumbnailPhoto | Set-Content "C:\folder\photo.jpg" -Encoding byte
设置照片:
$photo = [byte[]](Get-Content "C:\folder\photo.jpg" -Encoding byte)
Set-ADUser "UserName" -Replace @{thumbnailPhoto=$photo}
删除照片:
Set-ADUser "UserName" -Clear thumbnailphoto
您需要连接到远程 Exchange Online 会话:
$credential = Get-Credential
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $exchangeSession
一旦这样做,您将导入包含 Remove-UserPhoto
cmdlet 的模块,并且能够执行您想要的操作。
运行 PowerShell ISE 作为管理员。请确保您使用的帐户具有管理权限。
粘贴到顶部并点击播放按钮:
$credential = Get-Credential
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection Import-PSSession $exchangeSession
出现提示时,使用完整的电子邮件地址登录您的 Office 帐户:rsmith@xyz.org
:
PS C:>Set-UserPhoto -Identity "rsmith" -PictureData ([System.IO.File]::ReadAllBytes("C:\rsmith.jpg")) -Confirm:$false
或:
PS C:>Set-UserPhoto -Identity "Ryan L. Smith" -PictureData ([System.IO.File]::ReadAllBytes("C:\rsmith.jpg")) -Confirm:$false
确保此帐户是 Office 管理员帐户。
请注意,-Confirm:$false
是可选的。