Powershell - formatting issue in script
Exchange 2007 Standard SP1.I have a simplecode in Powershell script with just 1 pipe line:Get-Mailbox -ResultSize Unlimited -filter {ManagedFolderMailboxPolicy -ne $null} | format-table name,ManagedFolderMailboxPolicy -autoWhen I had run the script I received the error message:out-lineoutput : Object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not legal or not in the correct sequence. This is likely caused by a user-specified "format-list" command which is conflicting with the default formatting.From command line all is OK.How should I change the line to avoid the issue?Thanks.
June 17th, 2009 6:51pm
I didn't get this error, however can you check with below cmdlet?
Get-Mailbox -ResultSize Unlimited -filter {ManagedFolderMailboxPolicy -ne $null} | Select name, ManagedFolderMailboxPolicy | FT -auto
Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
June 17th, 2009 7:25pm
I didn't get this error, however can you check with below cmdlet?
Get-Mailbox -ResultSize Unlimited -filter {ManagedFolderMailboxPolicy -ne $null} | Select name, ManagedFolderMailboxPolicy | FT -auto
Thanks. Result is the same - negative.This part of code:
$members = (Get-Group SOME_GROUP_NAME).members | foreach {$_.name}
Write-Output "SOME_GROUP_NAME: $members"
Write-Output "Set SOME_POLICY_NAME for members of SOME_GROUP_NAME"
Get-Mailbox -resultSize unlimited | where { $members -contains $_.name} | Set-Mailbox -ManagedFolderMailboxPolicy "SOME_POLICY_NAME" -ManagedFolderMailboxPolicyAllowed
Write-Output "Get mailboxes with ManagedFolderMailboxPolicy"
#pause
$null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Get-Mailbox -ResultSize Unlimited -filter {ManagedFolderMailboxPolicy -ne $null} | format-Table SamAccountName,ManagedFolderMailboxPolicy -auto
June 17th, 2009 10:52pm
I split-ed up script to 3 part. Separately they work.
Free Windows Admin Tool Kit Click here and download it now
June 19th, 2009 12:40pm