{"id":168,"date":"2022-11-01T20:27:57","date_gmt":"2022-11-01T20:27:57","guid":{"rendered":"https:\/\/4laborant.ru\/?p=168"},"modified":"2022-11-01T20:28:46","modified_gmt":"2022-11-01T20:28:46","slug":"%d1%81%d0%ba%d1%80%d0%b8%d0%bf%d1%82-%d0%b4%d0%bb%d1%8f-%d0%b8%d0%bc%d0%bf%d0%be%d1%80%d1%82%d0%b0-%d1%83%d1%87%d0%b5%d1%82%d0%bd%d1%8b%d1%85-%d0%b7%d0%b0%d0%bf%d0%b8%d1%81%d0%b5%d0%b9-%d0%b2-ad","status":"publish","type":"post","link":"https:\/\/4laborant.ru\/?p=168","title":{"rendered":"\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0443\u0447\u0435\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 AD \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 Excel"},"content":{"rendered":"\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 PowerShell \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 AD. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0443\u0447\u0435\u0442\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Store the data from Users.csv in the $Users variable\n$Users = Import-csv C:\\PS\\&#91;\u0418\u041c\u042f_\u0424\u0410\u0419\u041b\u0410_\u0421_\u0423\u0427\u0415\u0422\u041d\u042b\u041c\u0418_\u0417\u0410\u041f\u0418\u0421\u042f\u041c\u0418].csv -Delimiter \u201c;\u201d\n\n#Loop through each row containing user details in the CSV file \nforeach ($User in $Users)\n{\n\t#Read user data from each field in each row and assign the data to a variable as below\n\t\t\n\t$Username = $User.username\n\t$Password = $User.password\n\t$Firstname = $User.firstname\n\t$Lastname = $User.lastname\n\t$OU = $User.ou \n\t$Password = $User.Password\n\t$Otchestvo = $User.Otchestvo\n\t$jobtitle = $User.jobtitle\n\t$department = $user.department\n\t$company = $user.company\n\t\n\t#Check to see if the user already exists in AD\n\tif (Get-ADUser -F {SamAccountName -eq $Username})\n\t{\n\t\t#If user does exist, give a warning\n\t\tWrite-Warning \"A user account with username $Username already exist.\"\n\t}\n\telse\n\t{\n\t\t#User does not exist then create the new user account\n\t\t\n        #Account will be created in the OU provided by the $OU variable read from the CSV file\n  New-ADUser `\n\t-SamAccountName $Username `\n\t-UserPrincipalName \"$Username@&#91;DOMAIN]\" `\n\t-Name \"$Lastname $Firstname $Otchestvo\" `\n\t-GivenName $Firstname `\n\t-Surname $Lastname `\n\t-Enabled $True `\n\t-DisplayName \"$Lastname $Firstname $Otchestvo\" `\n\t-Path $OU `\n\t-City $city `\n\t-company \"$company\" `\n\t-State $state `\n\t-StreetAddress $streetaddress `\n\t-OfficePhone $telephone `\n\t-EmailAddress $email `\n\t-title \"$jobtitle\" `\n\t-Department \"$department\"  `\n\t-AccountPassword (convertto-securestring $Password -AsPlainText -Force) -ChangePasswordAtLogon $False\n            \n\t}\n}\n<\/code><\/pre>\n\n\n\n<p>\u0412 \u043a\u043e\u0434\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0443\u0447\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 AD. <\/p>\n\n\n\n<p>\u0424\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 csv \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u044b, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Lastname,Firstname,Otchestvo,company,Username,Password,OU,jobtitle,department\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 PowerShell \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 AD. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0443\u0447\u0435\u0442\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438. \u0412 \u043a\u043e\u0434\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18,1,11],"tags":[],"_links":{"self":[{"href":"https:\/\/4laborant.ru\/index.php?rest_route=\/wp\/v2\/posts\/168"}],"collection":[{"href":"https:\/\/4laborant.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/4laborant.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/4laborant.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/4laborant.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=168"}],"version-history":[{"count":5,"href":"https:\/\/4laborant.ru\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions"}],"predecessor-version":[{"id":173,"href":"https:\/\/4laborant.ru\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions\/173"}],"wp:attachment":[{"href":"https:\/\/4laborant.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/4laborant.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/4laborant.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}