Skip to content

Instantly share code, notes, and snippets.

@TearTheSky
Created April 22, 2014 01:28
Show Gist options
  • Save TearTheSky/11162394 to your computer and use it in GitHub Desktop.
Save TearTheSky/11162394 to your computer and use it in GitHub Desktop.
write-output ($counter.tostring() + "人目のユーザアカウントを作成します。よろしいですか?")
$yesNo = read-host "(y / n)"
while ($yesNo -eq 'y')
{
try{
$name = Read-Host '作成したい新規参入者のユーザ名を入力してください。'
$server = [adsi]"WinNT://$env:computername"
$user = $server.Create("User", "$name")
#デフォルトパスワードはユーザ名と同じ
$user.SetPassword("$name")
$user.SetInfo()
Write-Output ("ユーザ " + $name + "を作成しました。")
# グループへ追加
$adsiGroup = [adsi]"WinNT://$env:computername/Administrators,Group"
$adsiGroup.Add($user.path)
}
catch{
Write-Output ("ユーザ " + $name + " の作成に失敗しました。")
}
$counter++
write-output ($counter.tostring() + "人目のユーザアカウントを作成します。よろしいですか?")
$yesNo = read-host "(y / n)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment