Powershell:Bulk add Domain users

Posted: June 9, 2015 in Scripts
Tags:

Create bunch of users using PowerShell

csv file with user details
With powershell You can create many users with a single line of code.During my preparation for MCSA exam on Windows Server 2012 i tried this.I attached file which contains 2 users,You can add as many as You like.This site didn’t allow me to upload csv extension,so before You try,the extension of file must be changed to .csv (instead 1.xls).

Save file on Your Windows Server 2012 server (in my case C:\),open powershell as admin and type next lines:

Import-csv “c:\1.csv” | ForEach-Object {new-aduser -name $_.name -UserPrincipalName $_.use
rprincipalname -DisplayName $_.displayname -givenName $_.givenname -surname $_.surname -path $_.path -profilepath $_.pro
filepath -homedrive $_.homedrive -HomeDirectory $_.homedirectory -AccountPassword (convertto-securestring $_.accountpass
word -asplaintext -force) -Enabled ([System.Convert]::toboolean($_.enabled)) -ChangePasswordAtLogon ([system.convert]::
ToBoolean($_.changepasswordatlogon)) }

Press Enter and user creation is done !.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s