locked
Customize Exchange 2007 Alias RRS feed

  • Question

  • I have an OU with about 250 users I need to create new mailboxes for.  The username standard is a shortened reverse method.  For example, Steve Johnson would be JOHNSOS.  I have a need to create the mailbox but use an alternate alias.  I remember doing this with character strings long ago in older versions of Exchange but am trying to nail down the PowerShell methodology.  The alias format I need for every user is first initial and last name so for this particular user....sjohnson.  The alias does not need to be truncated in any capacity.  Is there a single PowerShell command I can use to accomplish this for all users?  If I filter using the EMC to that OU I can obviously create all mailboxes at one time for these users however I cannot edit the alias so PowerShell seems to be the way to go...what type of script would I be looking at

    Thanks in advance :-)


    Dave Durand
    Wednesday, February 1, 2012 6:23 PM

Answers

  • ModernAge,

    If you look at the script, I am not using user ID.  I am pulling the users first and last name.  If those are populated correctly, then the script will make the alias firstinitiallastname.  That is of course if my script were correct.  See the corrected syntax below:

    Import-Csv c:\users.csv | ForEach-Object {
    $user = samaccountname
    $exalias = $_.firstname[0]+$_.lastname
    $displayname = $_lastname+","+$_.firstname
    enable-mailbox -identity $user -alias $exalias -database "server\database" -displayname $displayname
    }


    JAUCG
    Thursday, February 2, 2012 4:28 AM
  • Sorry for the delay in responding back.  Fortunately I got the one line I needed to assemble the alias I wanted to use however the rest of the scripts above needed some help.  Here is what I did.

    get-user -OrganizationalUnit "Mailbox Users" | select-object samaccountname,firstname,lastname,userprincipalname |export-csv c:\users.csv -notype 

    The above script simply required the OU string in quotes rather than in long form.  Also, unless I went with the userprincipalname field in my export, the next step would fail claiming the object did not exist in active directory.  I think the best bet is using the UPN for a more accurate process.  Here was the script that ultimately created the intended alias upon mailbox creation.

    Import-Csv c:\users.csv | ForEach-Object {
    $user = $_.userprincipalname
    $exalias = $_.firstname[0]+$_.lastname
    $displayname = $_.firstname+ " " +$_.lastname
    enable-mailbox -identity $user -alias $exalias -database "MAILBOXSERVER\MAILBOXDATABASE" -displayname $displayname
    }

    Ultimately this did the trick....thanks for your help everyone. :-)


    Dave Durand

    Thursday, February 9, 2012 4:49 PM

All replies

  • Take a look at this for the new-mailbox powershell cmdlet: http://technet.microsoft.com/en-us/library/aa997663(EXCHG.80).aspx

    You can make the alias based on their user name by going through steps similar to this:

    get-user -OrganizationalUnit ou=userou,dc=domain,dc=local | select-object samaccountname,firstname,lastname |export-csv c:\users.csv -notype

    Import-Csv c:\users.csv | ForEach-Object {
    $user = samaccountname
    $username = $_.firstname[0]+$_.lastname
    $displayname = $_lastname+","+$_.firstname
    enable-mailbox -identity $user -alias $exalias -database "server\database" -displayname $displayname
    }

    For the one off user, either use Powershell or manually change it in the Exchange Management Console.


    JAUCG
    Wednesday, February 1, 2012 8:43 PM
  • OK...I understand where you are going with the script however all user IDs are in the format of JOHNSOS and this would be the default alias when in reality I want every alias to take on the format sjohnson, first initial, entire last name with no dots, spaces, etc.  so what method can be used to generate an alias that differs from the actual AD username?  I kind of figured an export to csv would be part of the process.
    Dave Durand
    Wednesday, February 1, 2012 8:48 PM
  • ModernAge,

    If you look at the script, I am not using user ID.  I am pulling the users first and last name.  If those are populated correctly, then the script will make the alias firstinitiallastname.  That is of course if my script were correct.  See the corrected syntax below:

    Import-Csv c:\users.csv | ForEach-Object {
    $user = samaccountname
    $exalias = $_.firstname[0]+$_.lastname
    $displayname = $_lastname+","+$_.firstname
    enable-mailbox -identity $user -alias $exalias -database "server\database" -displayname $displayname
    }


    JAUCG
    Thursday, February 2, 2012 4:28 AM
  • Hello Dave,

     

    so what method can be used to generate an alias that differs from the actual AD username?

     

    You can just follow JAUCG’s suggestion to get user’s firstname and lastname by using get-user, then create new alias with

     

    $newalias=$firstname[0]+$lastname

     

    Thanks,

     

    Evan Liu

     

    TechNet Subscriber Support in forum

    If you have any feedback on our support, please contact tngfb@microsoft.com  


    Evan Liu

    TechNet Community Support

    Thursday, February 2, 2012 7:26 AM
    Moderator
  • Hi Dave,

     

    Any updates on this issue?

     

    Thanks,

     

    Evan Liu

     

    TechNet Subscriber Support in forum

    If you have any feedback on our support, please contact tngfb@microsoft.com  


    Evan Liu

    TechNet Community Support

    Monday, February 6, 2012 2:12 AM
    Moderator
  • Sorry for the delay in responding back.  Fortunately I got the one line I needed to assemble the alias I wanted to use however the rest of the scripts above needed some help.  Here is what I did.

    get-user -OrganizationalUnit "Mailbox Users" | select-object samaccountname,firstname,lastname,userprincipalname |export-csv c:\users.csv -notype 

    The above script simply required the OU string in quotes rather than in long form.  Also, unless I went with the userprincipalname field in my export, the next step would fail claiming the object did not exist in active directory.  I think the best bet is using the UPN for a more accurate process.  Here was the script that ultimately created the intended alias upon mailbox creation.

    Import-Csv c:\users.csv | ForEach-Object {
    $user = $_.userprincipalname
    $exalias = $_.firstname[0]+$_.lastname
    $displayname = $_.firstname+ " " +$_.lastname
    enable-mailbox -identity $user -alias $exalias -database "MAILBOXSERVER\MAILBOXDATABASE" -displayname $displayname
    }

    Ultimately this did the trick....thanks for your help everyone. :-)


    Dave Durand

    Thursday, February 9, 2012 4:49 PM