TechShizz | All posts tagged 'Bulk Tasks'

Creating users in Bulk with PowerShell

Finding Commands


Get-command *AD*





New-ADUser -Path "ou=User Accounts,dc=contoso,dc=com" -Name "Mary North"

-SAMAccountName "mary.north" -UserPrincipalName "[email protected]"

-EmailAddress "[email protected]" -GivenName "Mary" -Surname "North"

-Description "Sales Representative in Australia"

-Company "Contoso, Ltd." -Department "Sales"

-Office "Sydney"


Password Set


-AccountPassword (ConvertTo-SecureString -AsPlainText "Pa$$w0rd" -Force)

-ChangePasswordAtLogon $true -Enabled $true


Piped command


Get-ADUser "mary.north" | Set-ADUser -DisplayName "North, Mary"


Variable Command


$user = Get-ADUser "mary.north"

Set-ADUser $user -EmployeeNumber 12345





$UserList=IMPORT-CSV c:\users\administrator\documents\newusers.csv


# Step through Each Item in the List


FOREACH ($Person in $UserList) {


# Build Username




# Build Password from Firstname and Lastname




# Build the Displayname


$Name=$Person.Firstname+” “+$Person.Lastname


# Build and define Domain name




# Build User Principal Name




# Build and define Home Directory path




# Build and define which Organizational Unit to create User inside




# Create Account in Active Directory (AND HERE...WE...GO!)


New-ADUser -Name $Name –GivenName $Person.Firstname –Surname $Person.Lastname –DisplayName $Name –SamAccountName $Username -HomeDrive "H:" -HomeDirectory $HDrive –UserPrincipalName $UPN -Path $OU


# Set Password


Set-ADAccountPassword -Identity $Username -NewPassword (ConvertTo-SecureString -AsPlainText $Password -Force)


# Add User to Security Groups

Add-ADPrincipalGroupMembership -Identity $Username -MemberOf "Sales","Test"


# Enable Account

Enable-ADAccount -Identity $Username