header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Setting an Email address Primary
Last Post 22 Sep 2009 12:33 AM by Vishal Ramnani. 4 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Vishal RamnaniUser is Offline
New Member
New Member
Posts:68
Avatar

--
18 Sep 2009 01:46 AM
    Hey Guys

    I am trying to edit a mailbox's email addresses (proxyAddressCollection). when adding a new SMTP address in this field it gets set as Primary. how to make other one Primary in the Variable itself then set in the mailbox?

    Here is what i am trying...

    $mb = Get-Mailbox -id "User"
    $mb.emailaddresses.Add("SMTP:newemailID")
    $mb.emailaddresses.makeprimary(SMTP:oldemailID")

    It gives me an error below.

    Cannot convert argument "0", with value: "SMTP:oldemailID", for "MakePrimary" to type "System.Int32": "Cannot convert value "SMTP:OldEmailID" to type "System.Int32". Error: "Input string was not in a correct format.""
    At line:1 char:31
    + $mb.emailaddresses.MakePrimary <<<< ("SMTP:OldemailID")

    Any Ideas...

    Thanks in advance.



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

    --
    20 Sep 2009 05:52 AM
    is it possible guys??
    Vishal Ramnani
    MCITP - Exchange 2007, MCSE Messaging, MCTS - Win 2008 Config
    Mike PfeifferUser is Offline
    New Member
    New Member
    Posts:28
    Avatar

    --
    20 Sep 2009 04:12 PM
    It's giving you an error becuase you are trying to pass a string to the method, and it's expecting an integer. Use the index of the email address in the $mb.emailaddresses array:

    $mb.emailaddresses.makeprimary(0)

    Don't forget when you are done you still need to use set-mailbox to set the email address values:

    Set-Mailbox username -EmailAddresses $mb.emailaddresses

    Another thing to mention...you can pass an array of emailaddresses to Set-Mailbox -EmailAddress and by default it will set the first address as the primary, for example:

    Set-Mailbox username -EmailAddresses "user@domain.local","username@domain.local"

    or...

    This would add an additional email address leaving the existing primary address intact:

    $user = Get-Mailbox username
    $user.emailddresses+="user@domain.com"
    Set-Mailbox $user -EmailAddresses $user.emailaddresses
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    20 Sep 2009 11:54 PM
    You can simply do the following, the new PrimarySmtpAddress sets the email as the primary address (you may have to disable EmailAddressPolicyEnabled):

    Get-Mailbox user1 | Set-Mailbox -PrimarySmtpAddress user1@domain.com -EmailAddressPolicyEnabled $false


    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    Vishal RamnaniUser is Offline
    New Member
    New Member
    Posts:68
    Avatar

    --
    22 Sep 2009 12:33 AM
    Thanks Mike, That worked.

    To add here for others...

    We can find the index of the values in the this array as below.

    $mb.emailaddresses.Indexof("value in ProxyAddressString")

    Correct me if i am wrong here.

    Vishal Ramnani
    MCITP - Exchange 2007, MCSE Messaging, MCTS - Win 2008 Config
    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