Skip to content

Instantly share code, notes, and snippets.

@the-takeo
Last active June 17, 2016 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-takeo/f116f14e8be45a7ad328 to your computer and use it in GitHub Desktop.
Save the-takeo/f116f14e8be45a7ad328 to your computer and use it in GitHub Desktop.
Hyper-V_Server_Setting.bat

Hyper-V Serverのインストール後に必要な設定を行うbatファイルです。
Hyper-V Serverをワークグループで使うことを前提にしています。
(ドメイン環境で使う場合、この設定は不要です。少しの設定だけで使えるようになります)

Cドライブ直下に http://code.msdn.microsoft.com/HVRemote からダウンロードしたhvremote.wsfを保存したうえで
Hyper-V_Server_Setting.batを管理者として実行してください。
最後にコンピュータ名の変更を行うので、再起動が必要です。

また、Hyper-V Sercerを管理するクライアントにも設定が必要です。

  1. Cドライブ直下に http://code.msdn.microsoft.com/HVRemote からダウンロードしたhvremote.wsfを保存してください。
  2. 以下のコマンドを実行してください。%ServerName%%ServerUserName%の部分は適宜書き換えてください。
    cscript C:\hvremote.wsf /anondcom:grant
    winrm set winrm/config/client @{TrustedHosts=%ServerName%}
    cmdkey /add:%ServerName% /user:%ServerUserName% /pass
    (パスワードの入力を促されるので、サーバーのパスワードを入力してください)
rem ### 変数設定
set ServerName="ServerName"
set RemoteUserName="Administrator"
set IP="192.168.0.100"
set SubnetMask="255.255.255.0"
set GateWay="192.168.0.1"
rem ### Hyper-V Serverインストール後に行うべき作業
rem ### 参考:http://ascii.jp/elem/000/000/850/850959/
rem ### 管理者として実行することが必要
rem ### 2.ワークグループに参加(標準で有効になっているので変更の必要なし)
rem ### Wmic computersystem where name="%computername%" call joindomainorworkgroup name="WORKGROUP"
rem ### 3.リモート管理の構成を有効にする(標準で有効になっているので変更の必要なし)
rem ### 4.リモートデスクトップ接続の許可
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1
rem ### 5.ファイアーウォールの解放を行う
netsh advfirewall firewall set rule group="リモート デスクトップ" new enable=yes
netsh advfirewall firewall set rule group="ファイルとプリンターの共有" new enable=yes
netsh advfirewall firewall set rule group="Windows リモート管理" new enable=yes
netsh advfirewall firewall set rule group="リモート イベントのログ管理" new enable=yes
netsh advfirewall firewall set rule group="リモート ボリューム管理" new enable=yes
rem ### 6.ローカルPCのユーザーをHyper-V serverに登録する
rem ### サーバーのC:\直下にhvremote.wsfを保存する必要がある。
rem ### hvremote.wsfは"http://code.msdn.microsoft.com/HVRemote"から入手可能である
rem ### また、管理用ローカルPCでも同じファイルを用いて以下のコマンドを実行する
rem ### >cscript C:\hvremote.wsf /anondcom:grant
rem ### >winrm set winrm/config/client @{TrustedHosts=%ServerName%}
rem ### >cmdkey /add:%ServerName% /user:%ServerUserName% /pass
rem ### (パスワードの入力を求められる)
cscript C:\hvremote.wsf /add:%RemoteUserName%
rem ### 7.IPを設定する
netsh interface ip set address "ローカル エリア接続" static %IP% %SubnetMask% %GateWay%
rem ### 8.Windows Updateの停止(自動更新を止める必要がなければ設定の必要なし)
rem ### reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate" /t REG_DWORD /d 1 /f
rem ### 1.コンピュータ名の変更
wmic computersystem where name="%computername%" call rename name=%ServerName%
rem ### 以上
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment