![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Exchange 2007 - Mailbox management I have an Exchange 2007 question, we want to delete all email address except for the "PrimarySmtpAddress" under a user account. We know how to Uncheck "automatically update email address based on recipient policy. If you do a "get-mailbox XXXXX | fl" this list all information about the account The variable we want to change is "EmailAddresses" within the mailbox. We basically want to delete all "emailaddresses" except for the "PrimarySMTPAddress" Thanks in advance, Eric Sabo |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: Exchange 2007 - Mailbox management Try: $user = "test" $mailbox = Get-Mailbox $user $mailbox.EmailAddresses | foreach { if (!$_.IsPrimaryAddress -and ($_.PrefixString -eq "SMTP")) {$mailbox.EmailAddresses -= $_} } $mailbox | set-mailbox ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: Exchange 2007 - Mailbox management Sabo, Eric wrote:
http://groups.google.com/group/micro...e24530e1835b3c Willing to install/try or already have the Quest AD cmdlets? Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
My System Specs![]() | |||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Exchange 2007 - Mailbox management Shay, Thanks for the reply. So you are saying that this will delete all email addresses except for the primary adddress? "Shay Levi" <no@xxxxxx> wrote in message news:8766a9441c3118ca3090529d417c@xxxxxx
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Exchange 2007 - Mailbox management Yup, Make sure to test it, don't take anything for granted ![]() Basically, I've created a test user, added some email addresses to it and run the code. I suggest to log each user's addresses before and after the modification process. ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #6 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Exchange 2007 - Mailbox management Ran the script and that does not remove any of them. Is there a way I can clear all but the primary email address? "Shay Levi" <no@xxxxxx> wrote in message news:8766a9441c3118ca3090529d417c@xxxxxx
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #7 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Exchange 2007 - Mailbox management Try this: $user = "test" $mailbox = Get-Mailbox $user ## EmailAddresses before # $mailbox.EmailAddresses $mailbox.EmailAddresses | where {!$_.IsPrimaryAddress -and ($_.PrefixString -eq "SMTP")} | foreach {$mailbox.EmailAddresses -= $_.SmtpAddress} $mailbox | set-mailbox ## EmailAddresses after # $mailbox.EmailAddresses ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #8 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Exchange 2007 - Mailbox management I think I answered this problem in another forum and I don't think you can do it with the Exchange 2007 cmdlets. You can modify the user with the Quest AD set-qaduser cmdlet though. Or use VBScript. -- Jeffery Hicks MCSE, MCSA, MCT Microsoft PowerShell MVP http://www.scriptinganswers.com http://www.powershellcommunity.org http://jdhitsolutions.blogspot.com Now Available: WSH and VBScript Core: TFM Now Available: Windows PowerShell v1.0: TFM 2nd Ed. "Sabo, Eric" <sabo_e@xxxxxx> wrote in message news:OEGJhqnYIHA.220@xxxxxx
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #9 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Exchange 2007 - Mailbox management Hello Eric,
Eric; You may have stumbled over line wraps in Shay's example, so try this one, removing the @ from each line. (If the line doesn't start with an @, it is part of the previous line.) @$mailbox = Get-Mailbox $user @$addresses = $mailbox.EmailAddresses @$beforecount = $addresses.count @$mailbox.EmailAddresses | foreach { @if (!$_.IsPrimaryAddress -and ($_.PrefixString -eq "SMTP")) {$mailbox.EmailAddresses -= $_}} | set-mailbox @$addresses = $mailbox.EmailAddresses @$aftercount = $addresses.count @write-host "There were $beforecount email addresses" @write-host "There is now $aftercount email address" Karl | ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #10 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Exchange 2007 - Mailbox management FYI, the PowerShell version is working. ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||