none
Change AD users with Exchange 2013 mailboxes to mail users instead RRS feed

  • Question

  • We have a need to modify a large number of users in our AD who have Exchange 2013 mailboxes with forwarding turned on after a merger.  We've been instructed to remove their mailboxes (all email has been exported already) and turn those accounts in mail users instead, where we will then use their new external email address (parent email domain).  Our domains are still separate; no trusts or connections in any way. I can tell you that all of the user accounts are not in the same OU; they are spread out over many OUs as we have a large AD structure.  Just to reiterate, these are existing users; I am NOT creating new user accounts during this process. 

    So I'm looking for a script or shell command where I can feed in usernames/external email addresses, etc and have it create the mail user attributes.

    I already know the steps I'll use to mass delete their mailboxes.  Any questions, please ask.  Thanks in advance!


    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.


    • Edited by B0ndoo7 Wednesday, December 16, 2015 8:38 PM
    Wednesday, December 16, 2015 8:23 PM

Answers

  • So here's the end result and it works great:

    Step 1 - create a .csv file with two column headings (User, ExternalEmailAddress); the usernames go under the "User" column and the external email addresses go under the "ExternalEmailAddress" column.

    Step 2 - run the following cmdlet in the Exchange shell:

    Import-Csv .\<csv file name>|%{Enable-MailUser -Identity $_.User -ExternalEmailAddress $_.ExternalEmailAddress}

    You even get output on the screen showing the Users' names (display names) and the recipient type of "MailUser".  Thanks for the suggestions jrv and Bill!


    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.

    • Marked as answer by B0ndoo7 Friday, December 18, 2015 5:47 PM
    Friday, December 18, 2015 5:47 PM

All replies

  • How can you create user from an email address unless you just want to use the mail name as the name and account (samname).

    userid@maildom.com -> New-AdUser userid -userPrincipalName userid@domain.com -Password $pwd -PassThru | New-Mailbox

    Is this what you are asking?


    \_(ツ)_/

    Wednesday, December 16, 2015 9:02 PM
  • No, I don't believe so.  The "new-aduser" cmdlet is to create a new AD user object; I already have the users created.  Here's what I'm trying to accomplish:

    1. John Doe (AD user) is an existing AD user and has an Exchange 2013 mailbox that is currently forwarding all email to a new mailbox at the parent company

    2. I will delete the mailbox using the "disable-mailbox" cmdlet, which will remove the mailbox for deletion but leave the AD user account intact

    3. I believe I need to use the "set-mailuser" cmdlet to add email attributes (like the external SMTP address) so email destined for this user is automatically forwarded to the new, proper external email address.

    This is easily accomplished if doing it for a single or handful of users, but I need to do it for like 1800+ users.  I'm beginning to think the easiest way to do this is to put all of the commands properly formatted into a notepad doc and save it as a .ps1 file, then run it in the Exchange shell.  Still open to suggestions if anyone has anything.


    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.

    Thursday, December 17, 2015 2:17 PM
  • One of the great things about PowerShell is its pipeline processing approach.

    There is no need to enter the commands one at a time in the console, or to create a text file containing commands and run them one at a time.

    You can use Get-Content and ForEach-Object to easily repeat a command based on input from a text file. For example, suppose you have this text file, userList.txt:


    User 1
    User 2
    User 3
    

    Now you can run a command like this:


    PS C:\Scripts> Get-Content userList.txt | ForEach-Object { "Hello, $_" }
    

    The output of this command will be the following:


    Hello, User 1
    Hello, User 2
    Hello, User 3
    

    You can easily extrapolate from this example to run the Set-MailUser cmdlet in the Exchange Management Shell console to set an email address for any number of users based on text file input.

    -- Bill Stewart [Bill_Stewart]

    Thursday, December 17, 2015 4:11 PM
    Moderator
  • What you've written Bill is exactly what I was originally looking for.  While I'm better with Exchange cmdlets in the shell, I'm still not admittedly any good at scripting, which is why I posted the question/request for help here. 

    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.

    Thursday, December 17, 2015 5:10 PM
  • So here's the end result and it works great:

    Step 1 - create a .csv file with two column headings (User, ExternalEmailAddress); the usernames go under the "User" column and the external email addresses go under the "ExternalEmailAddress" column.

    Step 2 - run the following cmdlet in the Exchange shell:

    Import-Csv .\<csv file name>|%{Enable-MailUser -Identity $_.User -ExternalEmailAddress $_.ExternalEmailAddress}

    You even get output on the screen showing the Users' names (display names) and the recipient type of "MailUser".  Thanks for the suggestions jrv and Bill!


    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.

    • Marked as answer by B0ndoo7 Friday, December 18, 2015 5:47 PM
    Friday, December 18, 2015 5:47 PM