{"id":267,"date":"2019-07-03T13:45:46","date_gmt":"2019-07-03T10:45:46","guid":{"rendered":"https:\/\/blog.airmeno.ru\/?p=267"},"modified":"2019-07-17T14:00:31","modified_gmt":"2019-07-17T11:00:31","slug":"import-eksport-polzovatelej-active-directory","status":"publish","type":"post","link":"https:\/\/blog.airmeno.ru\/?p=267","title":{"rendered":"\u0418\u043c\u043f\u043e\u0440\u0442 &#8212; \u042d\u043a\u0441\u043f\u043e\u0440\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 Active Directory"},"content":{"rendered":"\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u0432\u0432\u043e\u0434\u0443 \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 Active Directory. \u0415\u0441\u043b\u0438 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0438\u043b\u0438 \u0434\u0432\u0443\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445, \u0442\u043e \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u043e\u043b\u0438 (\u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 GUI), \u0430 \u0435\u0441\u043b\u0438 \u0438\u0437 PowerShell, \u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 New-ADUser.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> New-ADUser -?<\/code><\/pre>\n\n\n\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>New-ADUser -Name \"MyName\" -DisplayName \"My Name\" -GivenName \"MyName\" -Surname \"MyName\" -SamAccountName \"myname\" -UserPrincipalName \"myname@domain.local\" -Path \"OU=Users,OU=MyOrganization,DC=Domain,DC=local\" -AccountPassword (Read-Host -AsSecureString \"Input Password\") -Enabled $true<\/code><\/pre>\n\n\n\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0432\u0435\u0441\u0442\u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f MyName.<\/p>\n\n\n\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f AD:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-AdUser myname -Properities *<\/code><\/pre>\n\n\n\n<p>\u0438\u043b\u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-AdUser myname -Properities * | Export-CSV \"C:\\Temp\\MyADUser.csv\" -NoTypeInformation -Encoding UTF8<\/code><\/pre>\n\n\n\n<p>\u0412\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0444\u0430\u0439\u043b:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-ADUser -Filter * -Properties * | Export-CSV \"C:\\Temp\\AllADUsers.csv\" -NoTypeInformation -Encoding UTF8<\/code><\/pre>\n\n\n\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0432 AD \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 .csv<\/p>\n\n\n\n<p>\u0421\u0430\u043c \u0444\u0430\u0439\u043b \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0432\u0438\u0434:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> FirstName;LastName;SamAccountName;Department;Password;OU\n Vladimir;Vladimirov;vvladimirov;Sales;Pa$$w0rd;OU=Users,OU=MyOU,DC=Domain,DC=ru<\/code><\/pre>\n\n\n\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 PowerShell \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 AD:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Import-Module activedirectory\nImport-Csv \"C:\\temp\\users2.csv\" -Delimiter \";\" | ForEach-Object {\n$upn = $_.SamAccountName + \"@domain.ru\"\n$uname = $_.LastName + \" \" + $_.FirstName\nNew-ADUser -Name $uname  -DisplayName $uname\n-GivenName $_.FirstName  -Surname $_.LastName\n-Department $_.Department  -Description $_.Department\n-UserPrincipalName $upn  -SamAccountName $_.samAccountName\n-Path $_.OU # \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 csv \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u0445 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \";\" -AccountPassword (ConvertTo-SecureString -AsPlainText $_.Password -Force)\n-PasswordNeverExpires $true `\n-Enabled $true\n}<\/code><\/pre>\n\n\n\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 .ps1 \u0438 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned<\/code><\/pre>\n\n\n\n<p>\u0424\u0430\u0439\u043b .csv \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 AD \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u043f\u0440\u0430\u0432\u043a\u0438 \u0441 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u043f\u043e\u043b\u044f\u043c.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u0432\u0432\u043e\u0434\u0443 \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 Active Directory. \u0415\u0441\u043b\u0438 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0438\u043b\u0438 \u0434\u0432\u0443\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445, \u0442\u043e \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u043e\u043b\u0438&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[21,22,8],"_links":{"self":[{"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=\/wp\/v2\/posts\/267"}],"collection":[{"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=267"}],"version-history":[{"count":1,"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":268,"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions\/268"}],"wp:attachment":[{"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.airmeno.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}