2011-08-09 10 views
1

Microsoft BPOSで期限切れにならないように、ユーザーパスワードを設定するpowershellスクリプトを実行しようとしています。 Microsoftのサポートからスクリプトを入手しましたが、動作しません。私は私をサポートするためにそれらに再度連絡することができますが、私はstackoverflowが速くなると思う!powershellエラーのヘルプ

私が得たスクリプトは次のとおりです。私は私のBPOSの資格情報の入力を求められます(私は管理者午前)、エラーが映像で見ることができ

$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++; 
} 

Powershell error

私はかなり新しいです私はこのエラー、任意のアイデアを修正する方法がわからないのですか?

ありがとうございます。

答えて

2

私は$mailboxes割り当てのためにこれを試してスクリプトでフォーマットしてあなたが少しを取得していると思う:

$mailboxes = $assigned | foreach-object { Get-XsHostedExchangeMailbox -SourceServer red001.mail.microsoftonline.com -SourceIdentity $_.identity -SourceAdminCredential $cred -SourceDetail Full } | select-object DisplayName, identity 

これは1行でなければなりません。そうでない場合は、メモ帳にポップアップして、改行を削除し、それをスクリプト(またはプロンプト)にコピー/ペーストします。

+0

あなたは正しいです、助けてくれてありがとう! – John

関連する問題