Manage Active Directory With PowerShell

How to create multiple accounts with powershell script

when you’re creating user accounts with active directory(GUI), you have to right click so many times and its time consuming.but with this script you can easily create multiple accounts continuously.This is also possible with importing scv also but if its only 10 or 20 accounts its easier to use this PowerShell script.This PowerShell can be run with the server or desktop(Windows 7) which has install rsat(Remote server administration tool) or domain controller(Windows 2008 R2)

1.Open the Active Directory PowerShell module from administrative tools


Here the script is locate in desktop.therefore from PowerShell navigate the script location.


type the script name and press enter


Now enter the first name of the user


Enter the last name of the user and enter the login name(Normally this should be first name.last or first name and first letter of the last name)



Enter the password for the user (This should comply your password policy).And if you want to add more accounts press “y”




This is the script.copy the script content to notepad and save as scriptname.ps1



Function CreateAdUSer
            do {
                    $fname=Read-Host "Enter The First Name"
                    $sname=Read-Host "Enter the Surname"
                    $Sam=Read-Host "Enter Login Name"
                    $upassword=(Read-Host -AsSecureString "Enter the password")
                    $continue=(Read-Host "Create another user account press y")
                       New-AdUser -DisplayName $fname" "$sname -name $fname -GivenName $fname -surname $sname -SamAccountname $sam -AccountPassword $upassword -UserPrincipalName $sam -Enabled $True
            while ($continue -eq "y")


Leave a Reply

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

You are commenting using your 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: