帮助解决 powershell 错误
我正在尝试运行 powershell 脚本来将用户密码设置为在 Microsoft BPOS 中永不过期。我从 Microsoft 支持处获取了该脚本,但它不起作用。我可以再次联系他们来支持我,但我认为 stackoverflow 会更快!
我得到的脚本是:
$cred = Get-Credential
$assigned = Get-MSOnlineUser -credential $cred -enabled | where-object { $_.subscriptionids -ge 0 } | Select-Object displayName, identity
$mailboxes = $assigned | foreach-object { Get-XsHostedExchangeMailbox -SourceServer red001.mail.microsoftonline.com -SourceIdentity $_.identity -SourceAdminCredential
$cred -SourceDetail Full } | select-object DisplayName, identity
$i = 0;
Foreach($element in $assigned) {
$mailboxes[$i].displayName = $assigned[$i].displayName;
$mailboxes[$i].identity= $assigned[$i].identity;
Set-MSOnlineUserPasswordNeverExpire -identity $mailboxes[$i].identity -passwordNeverExpire $true -Credential $cred
$i++;
}
我收到提示输入我的 BPOS 凭据(我是管理员),并且可以在图片中看到错误: Powershell 错误
我对 powershell 相当陌生,所以我不知道如何纠正这个问题错误,有什么想法吗?
提前致谢。
I am trying to run a powershell script to set user password to never expire in Microsoft BPOS. I got the script from Microsoft support but it doesn't work. I could contact them again to support me but I figure stackoverflow would be faster!
The script I got is:
$cred = Get-Credential
$assigned = Get-MSOnlineUser -credential $cred -enabled | where-object { $_.subscriptionids -ge 0 } | Select-Object displayName, identity
$mailboxes = $assigned | foreach-object { Get-XsHostedExchangeMailbox -SourceServer red001.mail.microsoftonline.com -SourceIdentity $_.identity -SourceAdminCredential
$cred -SourceDetail Full } | select-object DisplayName, identity
$i = 0;
Foreach($element in $assigned) {
$mailboxes[$i].displayName = $assigned[$i].displayName;
$mailboxes[$i].identity= $assigned[$i].identity;
Set-MSOnlineUserPasswordNeverExpire -identity $mailboxes[$i].identity -passwordNeverExpire $true -Credential $cred
$i++;
}
I get prompted for my BPOS credentials (I am an admin) and the error can be seen in the picture:
Powershell error
I am fairly new to powershell so I am not sure how to correct this error, any ideas?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您通过在脚本中进行格式化尝试一下
$mailboxes
分配:这应该是一行。如果不是,请将其弹出到记事本中,删除换行符,然后将其复制/粘贴到脚本中(或提示符中)。
I think you're getting bit by formatting in the script try this for the
$mailboxes
assignment:This should be a single line. If it isn't, pop it into notepad, remove the linebreaks and then copy/paste it into your script (or to the prompt).