Script for cloning an existing AD user account using VBscript or PowerShell

  • 1.4K Views
  • Last Post 12 August 2015
sampathmanova posted this 11 August 2015

Hi,
I am looking a vbscript or powershell script for me to clone an existing user account with its group membership we used to get too many request.
I tried some modification from existing script by google but this is only creating user account except group membership:
$instance=Get-ADUser -Identity "UserAccount1"
Get-ADUser newuser -properties * | New-ADUser -samaccountname pitchandi -Instance $Instance -givenName "Sam" -Surname "Mano" -displayName "Sam Mano" -name "Mano Sam" -EmailAddress "pitchandi@xxxxxxxxxxxxxxxx" -userPrincipalName "spitchandi-a@xxxxxxxxxxxxxxxx" -description "Windows Team" -Enabled:$true -path "OU=Chennai,OU=Asia,DC=TestLab,DC=com" -AccountPassword (ConvertTo-SecureString P@ssw0rd!123 -AsPlainText -force) -verbose
Is there any script which will use from input file or online command to copy existing user with group membership.
I am not a script guy but just tried my best.
Thank you,Sampath

gkirkpatrick posted this 12 August 2015

Hi Sampath,

 

I created a PS script module that will create new AD users from a CSV file, using an existing user object as a template, including

creating the group memberships. You can download it from here.

https://onedrive.live.com/redir?resid=492300F59B5137C8!73015&authkey=!AIGdB0hwQG1KpWk&ithint=file%2czip

 

Copy the two PS files into a folder called ProvisionADUsers, then use Import-Module command to import the module. After that you can

use New-ADUsersFromCSV <csv file name> <template user SAM account name>.

 

Let me know how it goes.

 

-gil

 

 

 

show

Close