Col*_*ole 5 powershell office365 powershell-3.0
我是365环境的全局管理员,并且Powershell中的Set-UserPhoto命令遇到问题。如果我用自己的用户名运行它,就可以正常工作,但是如果我使用其他人的用户名运行它,则会出错。我需要给自己一些访问权限来完成这项工作吗?我是365中的域管理员和全局管理员,因此我应该能够执行任何操作。
使用以下命令通过PowerShell 3.0连接:
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/?proxyMethod=RPS -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Run Code Online (Sandbox Code Playgroud)
我正在运行的命令:
Set-UserPhoto –Identity username -PictureData ([System.IO.File]::ReadAllBytes("C:\userpics\username.jpg"))
Run Code Online (Sandbox Code Playgroud)
适用于我的用户名,对于任何其他用户名,我都可以这样做:
代理命令'Set-UserPhoto -Identity:'username'-PictureData上的错误- 这里的数字滚动了一段时间 -Confirm:$ False'到服务器BN3PR0201MB1027.namprd02.prod.outlook.com:服务器版本15.01.0534.0000 ,代理方法RPS:WinRM客户端无法处理该请求。连接字符串的格式应为[://] [:] [/],其中传输是“ http”或“ https”之一。传输,端口和后缀是可选的。主机可以是主机名或IP地址。对于IPv6地址,将地址括在方括号内-例如“ http:// [1 :: 2]:80 / wsman“。更改连接字符串,然后重试请求。 PSComputerName:outlook.office365.com
小智 0
如果您处于混合模式并且缩略图属性已同步,则您只能在本地 Active Directory 中更改用户照片,而不能在 Office 365 Exchange PowerShell 会话中更改用户照片。
如果您未处于混合模式,您可以尝试以下示例代码:
Set-UserPhoto "username" -PictureData ([Byte[]] $(Get-Content -Path "C:\userpics\username.jpg" -Encoding Byte -ReadCount 0)) -Confirm:$false
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5639 次 |
| 最近记录: |