Добавление пользователей в домен из csv [power shell]
Добавлено: Чт ноя 01, 2018 5:58 pm
ITшный форум
https://forum.mytechnote.ru/
Код: Выделить всё
New-ADUser -Name "$userName" -Surname "$surname" -DisplayName "$surname $name $sname" `
-OfficePhone "$phone" -EmailAddress "$mail" -Department "$depart" -Title "$dolzhnost" `
-UserPrincipalName "$userName$domain" -GivenName "$name" -Office "$room" -OtherAttributes @{comment="$id"} `
-AccountPassword (ConvertTo-SecureString -AsPlainText "$defpass" -force) -enabled $true `
-ChangePasswordAtLogon $true -SamAccountName "$userName" -erroraction 'silentlycontinue' `
-path "OU=Managers,OU=Users,DC=test,DC=loc"
Код: Выделить всё
switch ($depart) {
"Директор" {$ou="director"; break}
"Отдел продаж" {$ou="sales"; break}
Default {$ou="others″; exit}
}
$path="OU=$ou,OU=Users,DC=test,DC=loc"