exceptions
Hello, I need to run the below command but I have some users who should not have the emailaddresspolicyenabled:$True. Get-Mailbox -ResultSize Unlimited | Where {$_.emailaddresspolicyenabled -like "false"} | Set-MailContact -emailaddresspolicyenabled:$True There are 6 users > User1; User1; User2; User3; User4; User5; User6. And I was wondering whether I could use exepctions in the above shell command?? Thanks, Graig
December 9th, 2009 10:59am

Hello Again, To achieve this either you can add them in condition in "Where-object" or Add some string e.g. "Exempted" in any custom Attribute to filter those mailboxes. Condition in where-object (Regular Expressions) Get-Mailbox -ResultSize Unlimited | Where {$_.emailaddresspolicyenabled -like "false" -and ! ($_.alias -Match "^ User1Alias|User2Alias|User3Alias|User4Alias|User5Alias|User6Alias$" )} | Set-Mailbox -emailaddresspolicyenabled:$True ! exclamation sign will negate the condition and the value btwn "^...$" will be matched with OR expression by | sign. Please do not leave space before and after alias. Custom Attribute: Get-Mailbox -ResultSize Unlimited | Where {$_.emailaddresspolicyenabled -like "false" -and $_.customattribute15 -notlike "Exempted"} | Set-Mailbox -emailaddresspolicyenabled:$True Hope this helps. Thanks. Vishal Ramnani | MCITP - Exchange 2007 | MCSE Messaging | MCTS - Win 2008 Config
Free Windows Admin Tool Kit Click here and download it now
December 9th, 2009 11:53am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics