Latest cmdlet of the week post updated!
This one had some cool tricks with New-QADUser so I thought I would cross-post the use cases here as well.
Scenario 1
One day your boss comes up to you and says “Hey, we need to do some performance testing against our AD so can you create 20,000 users?” Because you have Powershell and New-QADUser you say “no problem” and quickly pound out this:
foreach($user in 1..20000)
{
$UserName = "PerfTestUser$User"
$UserPassword = "P@ssw0rd123!"
$ExpiresOn = $((Get-Date).AddMonths(1))
$userDescription = "User added for Performance Testing on $(Get-date)`
and Expires on $ExpiresOn"
$user = New-QADUser -name $UserName `
-SamAccountName $UserName `
-Description $UserDescription `
-ParentContainer $parent`
-UserPassword $UserPassword
$user | Set-QADUser -AccountExpires ((Get-Date).AddMonths(1))
}
NOTE: Notice the back tick “`” at the end of each line of the New-QADuser command. This allows you to escape the line break and span multiple lines with single command.
Scenario 2
So, your boss was so impress that you were able to create the 20,000 users so quickly he decides to task you will importing a csv file with 3000 real users with real data. Again… no problem
$upwd = "P@ssw0rd123!"
$users = import-csv UserList.csv | New-QADUser -ParentContainer $parent `
-UserPassword $uPwd
$users | Enable-QADuser
Find the post Here: Active Directory cmdlet of the week “New-QADuser”
tshell :: Nov.26.2008 :: All :: No Comments »

