header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Powershell script to delete secondary smtp domains from mailbox
Last Post 11 Jul 2011 06:07 AM by cokely. 5 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
AbdulAUser is Offline
New Member
New Member
Posts:1
Avatar

--
22 Apr 2010 06:21 AM
    Hello
    We have recently migrated from Lotus Notes to Exchange. I would like to request a powershell script that does the following:
    For each user mailbox that has the "primary SMTP domain" that matches @abc.com, we want to delete the secondary smtp domain of @xyz.com from the user's list of proxyaddresses.
    Thanks in advance
    Vishal RamnaniUser is Offline
    New Member
    New Member
    Posts:68
    Avatar

    --
    25 Apr 2010 11:58 PM
    below script will do...

    Get-Mailbox -resultsize Unlimited | Foreach {
    $MBx = $_
    $MBx.emailaddresses | foreach {
    if ($_.smtpaddress -like "*@xyz.com" -and $_.isPrimaryAddress -eq $false) {$_.remove($_.smtpaddress)}
    }
    Set-Mailbox -id $MBx -emailaddresses $MBx.emailaddresses
    }

    Thanks.

    Vishal Ramnani
    MCITP - Exchange 2007, MCSE Messaging, MCTS - Win 2008 Config
    mdbilalUser is Offline
    New Member
    New Member
    Posts:5
    Avatar

    --
    27 Apr 2010 03:09 AM
    Hi Vishal,

    I am newbie.. after seeing your script I am encouraged to do some script on my own. My understanding on the orginal request is to delete email address @xyz.com if @abc.com exists and as primary. Amended to accomodate this. If I am wrong correct me.

    Get-Mailbox -resultsize Unlimited | Foreach {
    $hasABC = $False
    $hasXYZ = $False
    $MBx = $_
    $MBx.emailaddresses | foreach {if ($_.smtpaddress -like "*@abc.com" -and $_.isPrimaryAddress -eq $True) {$hasABC = $True;break}}
    if ($hasABC) {
    $MBx.emailaddresses | foreach {if ($_.smtpaddress -like "*@xyz.com" -and $_.isPrimaryAddress -eq $false) {$_.remove($_.smtpaddress);$hasXYZ = $True;break}}
    if ($hasXYZ) {Set-Mailbox -id $MBx -emailaddresses $MBx.emailaddresses}
    }
    }
    cokelyUser is Offline
    New Member
    New Member
    Posts:3
    Avatar

    --
    03 Jun 2011 06:22 AM
    I need to remove a secondary SMTP address from about 1500 mailboxes.  I can create a CSV, but I'm a little fuzzy on the script.  Any help is much appreciated.
    JorgUser is Offline
    New Member
    New Member
    Posts:15
    Avatar

    --
    05 Jun 2011 04:06 AM
    Hi

    Sorry, I'm not really sure what you are trying to do? Are you trying to remove the SMTP from the 1500 where it is a member of the csv? Or is the csv the input of mailbox's to modify? I think we need a bit more information on what exaclty you are tyring to do?

    Without understaniding the specifics, you can use:

    $inputInfo = import-csv -path "C:\temp\input.csv"

    and then call a foreach on the $inputInfo

    foreach ($row in $inputInfo)
    {
    #do stuff here
    }

    If you have column headings as the first row in your csv you can use the foreach like this:
    foreach ($row in $inputInfo)
    {
    $userEmail = $row.EmailAddress
    $username = $row.logonName
    $displayName = $row.FullName

    if ($userEmail -eq "something here")
    {
    #do stuff
    }

    }

    Beyond this general info, not much more I can say, please provide more specific info on what you are trying to do. And I suspect putting this post in your own thread would be more polite and garner more attention :)


    cokelyUser is Offline
    New Member
    New Member
    Posts:3
    Avatar

    --
    11 Jul 2011 06:07 AM
    Hi Jorg

    I have a CSV containing all of the exchange alias's of the names that need the email address removed. I also created a new thread with this question and more detail and it has yet to receive a reply. I'm a newbie at this, so be gentle.
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer