![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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) |
| | 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 Quote: > 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![]() |
| | #3 (permalink) |
| | Re: Exchange 2007 - Mailbox management Sabo, Eric wrote: Quote: > 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 > 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) |
| | 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 Quote: > > 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 > Quote: >> 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![]() |
| | #5 (permalink) |
| | 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 Quote: > 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 > Quote: >> 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 Quote: >>> 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![]() |
| | #6 (permalink) |
| | 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 Quote: > > 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 > Quote: >> 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![]() |
| | #7 (permalink) |
| | 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 Quote: > 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 > Quote: >> 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 Quote: >>> 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![]() |
| | #8 (permalink) |
| | 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 Quote: > 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 Quote: >> >> 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 >> Quote: >>> 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![]() |
| | #9 (permalink) |
| | Re: Exchange 2007 - Mailbox management Hello Eric, Quote: > 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 > Quote: >> 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 Quote: >>> 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 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) |
| | Re: Exchange 2007 - Mailbox management FYI, the PowerShell version is working. ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Thanks everyone for their input, we current have a vbscript that does > this I was just wondering if it could be done with powershell > > Thanks again! > > "Karl Mitschke" <kmitschke@xxxxxx> wrote in message > news:7063857f26c888ca307bffc2a207@xxxxxx > Quote: >> Hello Eric, >> Quote: >>> 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 >>>> 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 >>>>> 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 >>>>> >> >> 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![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Exchange 2007 Remove Mailbox after AD deletion | .NET General | |||
| Deleting A Folder In A User Mailbox In Exchange 2007 | PowerShell | |||
| Exchange 2007: cross org mailbox migration bulk from csv file | PowerShell | |||
| Exchange 2007 Bulk Mailbox Creation - Password? | PowerShell | |||
| Creating a new mailbox on Exchange 2007 | PowerShell | |||