Peguei a resposta de Brad acima e adicionei um pouco mais detalhadamente abaixo (obrigado Brad por me fazer pensar nessa direção):
Arquivo CSV de entrada:
cn,givenname,sn,sAMAccountName,displayname,UserPrincipalName
Joe Smith,Joe,Smith,jsmith,Joe Smith,jsmith@domain.com
Susan Johnson,Susan,Johnson,sjohnson,Susan Johnson,sjohnson@domain.com
Código:
$inputFile = Import-CSV <insert filepath here>
foreach($line in $inputFile)
{
## need to add quotes around DSN
$dsn = "`"cn="+$line.cn+",ou=userou,dc=domain,dc=com`""
$samid = $line.sAMAccountName
$ln = $line.sn
$fn = $line.givenname
$dn = $line.displayname
## need to add quotes around display name
$dn2 = "`"$dn`""
$upn = $line.UserPrincipalName
cmd /c "dsadd user $dsn -samid $samid -ln $ln -fn $fn -display $dn2
-upn $upn -mustchpwd yes -pwd TempP@assw0rd"
write-host `n
}
Boa sorte!