Created
April 22, 2014 01:28
-
-
Save TearTheSky/11162394 to your computer and use it in GitHub Desktop.
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
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