Why does it not work?

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #6505

    by Clinton at 2013-01-24 02:23:37

    Im trying to add a secondary smtp for one user.

    I know you can do it with a csv file but i want to do it with command line.

    Get-Mailbox | foreach {
    $user = Get-Mailbox Clinton
    $user.emailAddresses+="clinton@test.com"
    Set-Mailbox $user -emailAddresses $user.emailAddresses
    }

    But it wont work.

    by toybits at 2013-01-24 03:36:25

    I think you have to prefix it with "smtp:"

    Get-Mailbox | foreach {
    $user = Get-Mailbox Clinton
    $user.emailAddresses+="smtp:clinton@test.com"
    Set-Mailbox $user -emailAddresses $user.emailAddresses
    }

    I had to do something like this for a SIP address and that worked.

    by Takuu at 2013-01-29 05:47:38

    You are calling Get-Mailbox once already in the beginning and passing it via pipeline to the foreach structure. You do not need to call it again for each object, because you already have all that data. Now you just have to reference each mailbox object, with $_ later on in the pipeline. Supposing you wanted to assign everyone in your company the same secondary SMTP address (not recommended) you can use this:
    Get-Mailbox | ForEach-Object {
    $user = $_
    $user.emailAddresses += "smtp:clinton@test.com"
    Set-Mailbox $user -emailAddresses $user.emailAddresses
    }

    But supposing you wanted to give them their own email addresses specific to the user, say for example, in relation to the alias:

    Get-Mailbox | ForEach-Object {
    $user = $_
    $user.emailAddresses += ("smtp:" + $user.alias + "@test.com")
    Set-Mailbox $user -emailAddresses $user.emailAddresses
    }

You must be logged in to reply to this topic.