简体   繁体   English

我从哪里获得 Powershell Cmdlet Remove-UserPhoto

[英]Where Do I Get the Powershell Cmdlet Remove-UserPhoto

I cannot find this anywhere on the web and am in need of an answer so I can remove all user photos from profiles in our Azure AD account.我在网络上的任何地方都找不到这个问题,我需要一个答案,以便我可以从 Azure AD 帐户的个人资料中删除所有用户照片。 Microsoft so kindly documents how to use Get-UserPhoto and Remove-UserPhoto , but does not explain how to actually get the Cmdlet.微软非常友好地记录了如何使用Get-UserPhotoRemove-UserPhoto ,但没有解释如何实际获取 Cmdlet。

I event went to their docs page for connecting to Azure Active Directory in Powershell , but that was no help either.我访问了他们的文档页面以连接到 Powershell 中的 Azure Active Directory ,但这也没有帮助。 It allowed me to download the AzureAD module (thinking that I needed it to run those Cmdlets), but no luck.它允许我下载 AzureAD 模块(认为我需要它来运行那些 Cmdlet),但没有运气。 Anyone tell me how in the world do I get the module that contains those commands?有谁告诉我,我到底是如何获得包含这些命令的模块的?

Updated Question: We only using Office 365. We do not have any on-site Exchange server, so how am I supposed to execute Exchange PowerShell scripts without it?更新的问题:我们只使用 Office 365。我们没有任何现场 Exchange 服务器,那么没有它我应该如何执行 Exchange PowerShell 脚本? How would any administrator do this?任何管理员会如何做到这一点? It's hard for me to believe that I'm the only idiot out there that needs to remove photos from the profiles in Office 365 and would like to do this in an automated fashion.我很难相信我是唯一一个需要从 Office 365 中的配置文件中删除照片并希望以自动化方式执行此操作的白痴。

The other problem I'm seeing is that when I browse to our user list, the photos don't appear in the User list in Azure.我看到的另一个问题是,当我浏览到我们的用户列表时,照片没有出现在 Azure 的用户列表中。 But if I go to random O365 apps (like Teams for instance), the profile picture appears.但是,如果我访问随机的 O365 应用程序(例如 Teams),则会出现个人资料图片。

You need to connect to your remote Exchange Online session:您需要连接到远程 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

As soon as you do that, you will import the module that contains Remove-UserPhoto cmdlet and will be able to do what you want.一旦您这样做,您将导入包含Remove-UserPhoto cmdlet 的模块,并且将能够执行您想要的操作。

Get a Photo:获取照片:

$user = Get-ADUser "UserName" -Properties thumbnailPhoto
$user.thumbnailPhoto | Set-Content "C:\folder\photo.jpg" -Encoding byte

Set a Photo:设置照片:

$photo = [byte[]](Get-Content "C:\folder\photo.jpg" -Encoding byte)
Set-ADUser "UserName" -Replace @{thumbnailPhoto=$photo}

Remove a Photo:删除照片:

Set-ADUser "UserName" -Clear thumbnailphoto

Run PowerShell ISE as administrator.以管理员身份运行 PowerShell ISE。 Make sure the account you use has administrative rights.确保您使用的帐户具有管理权限。

Paste into top and hit play button:粘贴到顶部并点击播放按钮:

$credential = Get-Credential
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection Import-PSSession $exchangeSession

When prompted, sign into your Office account with the full email address: rsmith@xyz.org :出现提示时,使用完整的电子邮件地址登录您的 Office 帐户: rsmith@xyz.org

PS C:>Set-UserPhoto -Identity "rsmith" -PictureData ([System.IO.File]::ReadAllBytes("C:\rsmith.jpg")) -Confirm:$false

or:要么:

PS C:>Set-UserPhoto -Identity "Ryan L. Smith" -PictureData ([System.IO.File]::ReadAllBytes("C:\rsmith.jpg")) -Confirm:$false

Make sure that this account is an Office admin account.确保此帐户是 Office 管理员帐户。 Note that the -Confirm:$false is optional.请注意, -Confirm:$false是可选的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何导入新的PowerShell cmdlet? - How do I import a new PowerShell cmdlet? 如何在没有Remove-PrinterDriver cmdlet的情况下使用Powershell删除打印机驱动程序 - How do I delete a printer driver using Powershell without the Remove-PrinterDriver cmdlet 如何找到 PowerShell cmdlet 的模块? - How do I find the module for a PowerShell cmdlet? Powershell Remove-Variable cmdlet,我需要在每个函数/脚本块的末尾调用它吗? - Powershell Remove-Variable cmdlet, do I need to call it at the end of each function/scriptblock? 我在哪里可以找到对象类文档的PowerShell cmdlet? - Where can i find PowerShell cmdlet to Object Class documentation? 我如何在 powershell 的 foreach 循环中嵌套另一个 cmdlet - How do i nest another cmdlet in foreach loop in powershell 如何隐藏PowerShell cmdlet(Move-VM)结果? - How do I suppress PowerShell cmdlet (Move-VM) results? 如何确定是否指定了PowerShell Cmdlet参数值? - How do I determine if a PowerShell Cmdlet parameter value was specified? PowerShell - 使用与函数相同的名称覆盖该 cmdlet 的名称时,如何在函数中调用该 cmdlet? - PowerShell - How do I call a cmdlet in a function when overriding that cmdlet's name with the same name as the function? “Get-FileMetaData”不是 Powershell 中的 Cmdlet - “Get-FileMetaData” not Cmdlet in Powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM