How to create, copy and remove Active Directory users using PowerShell

How to create, copy and remove Active Directory users using PowerShell


One of the most fundamental and often repeated task by an administrator is to create, copy or remove an Active directory user. Thanks to the New-ADUser cmdlet, it is extremely simple. Below are the PowerShell scripts to create, copy and remove an Active Directory user.


Create Active Directory user:


  1. #Create a new Active Directory user
  2. New-ADUser -Name "John Doe" -GivenName "John" -Surname "Doe" -SamAccountName "jdoe" -UserPrincipalName "jdoe@abc.com" -AccountPassword (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force) -Enabled $true -Path "OU=Employees,DC=abc,DC=com"


This command creates a new user under the name “John Doe”, with other attributes like surname, SamAccountName, UserPrincipalName and AccountPassword. The user is enabled and stationed under the OU – “Employees” in the domain -- “abc.com”



Copy Active Directory user:


  1. #Copy an existing Active Directory user
  2. Get-ADUser -Identity "jdoe" | New-ADUser -Name "Jane Doe" -SamAccountName "jdoe2" -UserPrincipalName "jdoe2@abc.com" -Path "OU=Employees,DC=abc,DC=com"


This command retrieves the user account "jdoe" to get its attributes and creates a new user account named "Jane Doe" with the same. The only exception here are the name and SAM account name, which are set to "Jane Doe" and "jdoe2", respectively. The new user account is placed in the OU – "Employees".



Remove Active Directory user:


  1. #Remove an Active Directory user
  2. Remove-ADUser -Identity "jdoe" -Confirm:$false


The third command removes the user account "jdoe" with confirmation set to false, meaning there won’t be any prompt before deleting. 


These steps are easier when only a handful of accounts are to be handled. But when there are a large amount of users involved in the process, there are certain ways to get that done easily.



To perform bulk operations associated with the above activities these steps will help achieve them easily.


  • Create a template account
  • Copy account attributes (we will use the -Instance parameter)
  • Add the new user to the Accounts group
  • Verification of user attributes and group membership
  • Creating new Active Directory users in bulk