Skip to content

Instantly share code, notes, and snippets.

@usaturn
Created April 1, 2016 11:23
Show Gist options
  • Save usaturn/73a7482cd1d4c0f1025ad5b44a49aed4 to your computer and use it in GitHub Desktop.
Save usaturn/73a7482cd1d4c0f1025ad5b44a49aed4 to your computer and use it in GitHub Desktop.
Windows のローカルアカウントを作成する時に ID, コンピュータ名, パスワード の tsv ファイルを読ませて、コマンドを生成する
#!/usr/bin/gawk
/^.+/{
LOCALUSER=$1
HOSTNAME=$2
PASSWORD=$3
printf "powershell Start-Process powershell.exe -Verb runas\
\nRename-Computer %s\
\n(Get-WmiObject win32_TerminalServiceSetting -Namespace root\\cimv2\\TerminalServices).SetAllowTSConnections(1)\
\nNET USER %s /add\nNET USER %s %s\
\nwmic useraccount where \"Name='%s'\" set PasswordExpires=FALSE\
\nnet localgroup \"Power Users\"%s /add\
\nnet localgroup \"Remote Desktop Users\" %s /add\n\n",
HOSTNAME, LOCALUSER, LOCALUSER, PASSWORD, LOCALUSER, LOCALUSER, LOCALUSER
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment