ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Powershell to add alias to users mailbox

    IT Discussion
    exhcnage powershell
    3
    9
    2.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User
      last edited by A Former User

      I'm looking to use a powershell script which needs to filter it down to our specific company either buy using our exchange domain (@test.com) or our local domain (test.parentcompany.local) or using the company field in AD Users (I don't think that one's possible). Then it needs to set an alias of the mailbox as First Initial + [email protected]. We currently use [email protected]. The primary email should stay that (the alias should not show up on reply to or anything). Also I need it to handle duplicates by writing a log, How would I do that?

      Here's what I've put together so far, not sure if it will work or not..

      $Mailboxes = Get-Mailbox –Filter {Emailaddresses –Like "*@test.com"} 
      $Useralias =(($_.FirstName.Substring(0,1)) + ($_.LastName))
      Foreach ($Mailbox in $Mailboxes) { $NewAddress = $Useralias + "@test.com" $Mailbox.EmailAddresses += $NewAddress Set-Mailbox -Identity $Mailbox.Alias -EmailAddresses $Mailbox.EmailAddresses }
      
      1 Reply Last reply Reply Quote 1
      • GregoryHallG
        GregoryHall
        last edited by

        I usually use AD modify for this.. much easier and has a rollback feature in case you mess something up.
        http://admodify.codeplex.com/

        Let me know if that works for you if not then I will look over the script and test it on a clean AD for you.

        1 Reply Last reply Reply Quote 1
        • ?
          A Former User
          last edited by A Former User

          So ADModify will add the second SMTP address to the exchange mailbox but, if you try to send to that it fails. Any ideas why?

          When you type the email in the to field in outlook it displays this message at the top "This e-mail message cannot be delivered to Email" because the e-mail address is no longer valid.

          1 Reply Last reply Reply Quote 0
          • DashrenderD
            Dashrender
            last edited by

            Do you have any filtering going on in front of Exchange? For example I use Appriver to filter all my incoming mail.

            ? 1 Reply Last reply Reply Quote 0
            • ?
              A Former User @Dashrender
              last edited by

              @Dashrender said:

              Do you have any filtering going on in front of Exchange? For example I use Appriver to filter all my incoming mail.

              We have proof point but it just filters Spam https://www.proofpoint.com/ And they aren't showing up in there. We have like 20 domains (from all our companies) on the Exchange server so I can't say I know everything going on, on the exchange servers.

              1 Reply Last reply Reply Quote 0
              • DashrenderD
                Dashrender
                last edited by

                Look at your MX records - where is mail being delivered to first? Then walk the delivery path, hopefully you'll find who's hanging you up.

                ? 1 Reply Last reply Reply Quote 1
                • ?
                  A Former User @Dashrender
                  last edited by A Former User

                  @Dashrender said:

                  Look at your MX records - where is mail being delivered to first? Then walk the delivery path, hopefully you'll find who's hanging you up.

                  Our public MX Records don't matter internally it goes straight to exchange. Also I'm pretty sure that's not the issue based on it saying "This e-mail message cannot be delivered to EmailAddy because the e-mail address is no longer valid."

                  1 Reply Last reply Reply Quote 0
                  • ?
                    A Former User
                    last edited by

                    So if I send it externally it works, just internally it wants you to use the first.last email.

                    1 Reply Last reply Reply Quote 0
                    • ?
                      A Former User
                      last edited by

                      And oddly it just started working internally. I guess it just needed a bit more time. (I applied it before lunch).

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post