Created
July 30, 2020 03:33
-
-
Save orlea/bfab0cb92d688a3e6646b2a82cdbb924 to your computer and use it in GitHub Desktop.
単一グループ単一OUに一括でADユーザ追加するやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Start-Transcript ((Get-Date).Tostring("yyyyMMdd")+".log") -Append | |
$userlist = Import-Csv .\userlist.csv | |
$password = ConvertTo-SecureString "default-password" -AsPlainText -Force | |
$ou = "OU=hoge,DC=fuga,DC=company,DC=co,DC=jp" | |
$group = "group-name" | |
for ($i = 0; $i -lt $userlist.Count; $i++) { | |
New-ADUser $userlist[$i].id -Surname $userlist[$i].id -DisplayName $userlist[$i].id -Path $ou -AccountPassword $password -Enabled $true | |
Add-ADGroupMember -Identity $group -Members $userlist[$i].id | |
} | |
Stop-Transcript |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"id" | |
"lab-user1" | |
"lab-user2" | |
"lab-user3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment