Skip to content

Instantly share code, notes, and snippets.

@TearTheSky
Created November 21, 2013 06:44
Show Gist options
  • Save TearTheSky/7577027 to your computer and use it in GitHub Desktop.
Save TearTheSky/7577027 to your computer and use it in GitHub Desktop.
架空の会社の情シスになってActive Directoryを管理しなきゃいけなくなったので、CSVに書かれたユーザを一括で登録するスクリプトを作りました。
import-module ActiveDirectory
$company = 'tearthesky.com'
$usersOU = 'CN=Users,DC=tearthesky,DC=com'
write-host "Drop New Users List(CSV File)"
$csvFilePath = read-host
$newUsers = import-csv $csvFilePath
foreach($aUser in $newusers){
$aPassword = ConvertTo-SecureString $aUser.パスワード -AsPlainText -Force
New-ADUser -Name $aUser.アカウント名`
-SamAccountName $aUser.アカウント名 `
-UserPrincipalName $aUser.アカウント名 `
-GivenName $aUser.名 `
-Surname $aUser.姓 `
-DisplayName $aUser.表示名 `
-Path $usersOU `
-Company $company `
-Division $aUser.事業部 `
-Department $aUser.部署 `
-Office $aUser.勤務先 `
-AccountPassword $aPassword `
-ChangePasswordAtLogon $false `
-Title $aUser.役職 `
-Manager $aUser.上司
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment