We had to rebuild our test environment and the chap that had created all the test accounts in AD no longer works for the company, so after a bit of digging I came with this script:
Import-Module ActiveDirectory
for($i = 1; $i -le 100; $i++){
$accountname=[string]::format("crmtest{0}",$i)
$principal=[string]::format("{0}@dev.com",$accountname)
$password="P@ssw0rd"
New-ADUser -SamAccountName $accountname -Name $accountname -UserPrincipalName $principal -AccountPassword (ConvertTo-SecureString -AsPlainText $password -Force) -Enabled $true -PasswordNeverExpires $true -Path 'CN=Users,DC=dev,DC=com'
}
No comments:
Post a Comment