Код:
$objOUa = [ADSI]"LDAP://OU=a,dc=kakoitotam,dc=local"
$objOUb = [ADSI]"LDAP://OU=b,dc=kakoitotam,dc=local"
$Class = "organizationalUnit"
"comp","comp2" | Foreach {
$OU= "OU=$_"
$objOU = $objOUa.create($Class, $OU)
$objOU.SetInfo()
$objOU = $objOUb.create($Class, $OU)
$objOU.SetInfo()
}
Для компьютеров:
Код:
$SobjOU = [ADSI]"LDAP://OU=kakayatotam,dc=kakoitotam,dc=local"
7..15 | Foreach {
$SobjComputer = $SobjOU.Create("computer", "CN=PC_$_")
$SobjComputer.Put("sAMAccountName", "PC_$_$")
$SobjComputer.Put("userAccountControl", 4096)
$SobjComputer.SetInfo()
}