This guide explains how to bulk import users into Exchange using CSV and Powershell
Create a CSV File
The first step is to get a CSV file with all your email addresses in and create different columns that contain the formatted data you want. This will take some skills in Excel to complete but once done you will need several columns with the names
Alias,Firstname, Lastname,Name,UPN,SAM,OUpath,AddressBook,Database,Password
These fields will provide the data for
Alias - Exchange Alias
FirstName - Users First Name
LastName - Users Last Name
UPN - Users login containing their domain name @cscm.co.uk for example
SAM - Users pre Windows2000 login name for domain
OUPath - Organisational Unit Path in Active Directory
AddressBook - Users Global Address Book
Database - Mailbox Database
Password - Users Password
Test Access to CSV File
The Excel file needs to be saved as a CSV file in a location that is accessible from the Exchange Server. In this example we use C:\IT Support\users.csv
Now to access the CSV file you can use this cmdlet
$users = Import-CSV "C:\IT Support\users.csv"
The result of this cmlet should show as above the details from the CSV file for all of the users, in this example we show one user.
Import a User
The PowerShell command to import the users is
Import-CSV "C:\IT Support\users.csv" | foreach {New-Mailbox -Name $_.name -Alias $_.alias -Database "Database NewDatabase" -OrganizationalUnit $_.OUpath -UserPrincipalName $_.UPN -SamAccountName $_.SAM -FirstName $_.Firstname -LastName $_.Lastname -Password (ConvertTo-SecureString $_.password -AsPlainText -Force) -ResetPasswordOnNextLogon $false -AddressBookPolicy $_.AddressBook}
What happens here is that the Import-CSV file reads the CSV file, we then pipe the output to the command foreach which for each row in the output it applies the cmdlet New-Mailbox.
Then in the New-Mailbox cmdlet we have variables that read the CSV column titles and apply the content to the cmdlet. For example the columns title Name is applied as $_.name
The password content is converted to a PlainText field so that it can be imported and not have to be entered manually into a credentials window.
You are now able to bulk Import Users into Exchange and Active Directory without the need to enter them manually.
No comments:
Post a Comment