Make a Script to Create Multiples Users Using a Template Account in Exchange 2007


Create users can be a very easy task if you use scripts and templates.

Now we need:

  1. A CSV file NewUsers.csv and following data Name, User principal Name, Organizational Unit and Mailbox database:
    Name,UPN,OU,edb
    Ramirez,ramirez@Mydomain.loc,Mydomain.loc/Mydomain/Users,Mailbox database

  2. Create a Mailbox Template and configure with parameters that you want, for example: _TemplateComercial

  3. Create a script and save it, for example: filename.ps1
    Param(
    [string] $Template,
    [string] $CSVFile
    )
    $temp=get-mailbox $Template
    $Pass=convertto-securestring Password123 -asplaintext -force
    import-csv $CSVFile | foreach-object -process {new-mailbox -name $_.name -userprincipalname $_.UPN -organizationalunit $_.OU -database $_.EDB -password $pass -resetpasswordonnextlogon $true -templateinstance $temp}

  4. Save your script in you exchange installation for example:
    D:\Program Files\Microsoft\ExchangeServer\scripts\filename.ps1

  5. Run your script from EMS (Exchange Management Shell):
    filename.ps1 –Template _TemplateComercial –CSVFile “c:\NewUsers.csv”

Comentarios