Powershell AD – Test Accounts anlegen

$fnames = @(
‘Joern’
‘Manfred’
)
$lnames = @(
‘Walter’
‘Papst’
)
$secpass = Read-Host -Prompt ‘Password’ -AsSecureString
$ou = “OU=User Accounts,OU=User,OU=ORG,DC=ndsedv,DC=de”
foreach ($fname in $fnames){
foreach ($lname in $lnames){
$name = $lname.TOUpper() + ” $fname”
$sam = “$fname$lname”
$upn = “$sam@ndsedv.de”
New-ADUser -Name $name -SamAccountName $sam -UserPrincipalName $upn -AccountPassword $secpass -Path $ou -Enabled $true
}
}

Powershell AD Test Accounts anlegen