My Tracking

My Tracking

記憶力の低下が気になるアラフォー男の備忘録

WindowsServer2016(ServerCore)にPowershellで初期設定する。

下記で、インストールしたWindowsServer2016(ServerCore)に初期設定を行う。

インストールしたWindowsServer2016は、ServerCoreモードでインストールしたため、 DOSプロンプトから、Powershellを起動し、Powershellコマンドベースの初期設定を行う。

検証環境

検証環境は、下記の前提に基づく。

  • Windows10にインストールされたHyper-vホストに仮想マシンを作成する。
  • 作成した仮想マシンにWindowsServer2016 Technical Preview 5 をインストールする。
  • インストール際は、ISOを利用し、新規インストールする。
  • ServerCoreモードでインストールし、GUIはインストールしない。
  • ServerCoreモードでインストール後は、極力Powershellで初期セットアップを行う。

※以降の手順は、検証のための手順のため、公式の手順などではないです。

やること

以下の作業をPowershellで実施する。

  • コンピュータ名の変更。
  • IPアドレスの変更。
  • IP v6の無効化。
  • Windows ファイアーウォールの無効化。

Powershellの起動

下記のとおり、DOSプロンプト上でPowershellを起動し、以降の作業を実施する。

C:\Users\Administrator>powershell
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS C:\Users\Administrator>

コンピュータ名の変更

Rename-Computerコマンドで、コンピュータ名を変更する。

PS C:\Users\Administrator> Rename-Computer wind2016
警告: 変更は、コンピューター WIN-2V3T40SPO6L の再起動後に有効になります。
PS C:\Users\Administrator>

【実行例】

IPアドレスの設定

まずは、Get-NetAdapterコマンドで、該当するインターフェースの番号を取得する。

PS C:\Users\Administrator> Get-NetAdapter

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
イーサネット              Microsoft Hyper-V Network Adapter             2 Up           00-15-5D-03-04-0E       100 Mbps

その後、New-NetIPAddressでIPアドレスを設定する。

PS C:\Users\Administrator> New-NetIPAddress -InterfaceIndex 2 -IPAddress "192.168.3.16" -AddressFamily IPv4 -PrefixLength 24 -DefaultGateway "192.168.3.1"

【Get-NetAdapter実行例】

【New-NetIPAddress実行例】

【New-NetIPAddress出力例】

IP v6の無効化

次に、IP v6を無効化する。 まずは、Get-NetAdapterbindingで現在のネットワークアダプタの設定一覧を表示する。

PS C:\Users\Administrator> Get-NetAdapterbinding

次に、Disable-NetAdapterBindingでIP v6を無効化する。

Disable-NetAdapterBinding -InterfaceAlias "イーサネット" -ComponentID ms_tcpip6

最後に、Get-NetAdapterbindingで現在のネットワークアダプタの設定一覧を改めて表示する。

PS C:\Users\Administrator> Get-NetAdapterbinding

【Get-NetAdapterbinding実行例】

【Disable-NetAdapterBinding実行例】

WindowsFirewallの無効化

セキュリティ的に推奨はされないが、一旦WindowsFirewallを無効化する。 まずは、下記で、一括無効化し、

PS C:\Users\Administrator> Get-NetFirewallProfile | Set-NetFirewallProfile -Enabled false

下記で、状態を確認する。

PS C:\Users\Administrator> Get-NetFirewallProfile
Name                            : Domain
Enabled                         : False
DefaultInboundAction            : NotConfigured
DefaultOutboundAction           : NotConfigured
AllowInboundRules               : NotConfigured
AllowLocalFirewallRules         : NotConfigured
AllowLocalIPsecRules            : NotConfigured
AllowUserApps                   : NotConfigured
AllowUserPorts                  : NotConfigured
AllowUnicastResponseToMulticast : NotConfigured
NotifyOnListen                  : False
EnableStealthModeForIPsec       : NotConfigured
LogFileName                     : %systemroot%\system32\LogFiles\Firewall\pfirewall.log
LogMaxSizeKilobytes             : 4096
LogAllowed                      : False
LogBlocked                      : False
LogIgnored                      : NotConfigured
DisabledInterfaceAliases        : {NotConfigured}

Name                            : Private
Enabled                         : False
DefaultInboundAction            : NotConfigured
DefaultOutboundAction           : NotConfigured
AllowInboundRules               : NotConfigured
AllowLocalFirewallRules         : NotConfigured
AllowLocalIPsecRules            : NotConfigured
AllowUserApps                   : NotConfigured
AllowUserPorts                  : NotConfigured
AllowUnicastResponseToMulticast : NotConfigured
NotifyOnListen                  : False
EnableStealthModeForIPsec       : NotConfigured
LogFileName                     : %systemroot%\system32\LogFiles\Firewall\pfirewall.log
LogMaxSizeKilobytes             : 4096
LogAllowed                      : False
LogBlocked                      : False
LogIgnored                      : NotConfigured
DisabledInterfaceAliases        : {NotConfigured}

Name                            : Public
Enabled                         : False
DefaultInboundAction            : NotConfigured
DefaultOutboundAction           : NotConfigured
AllowInboundRules               : NotConfigured
AllowLocalFirewallRules         : NotConfigured
AllowLocalIPsecRules            : NotConfigured
AllowUserApps                   : NotConfigured
AllowUserPorts                  : NotConfigured
AllowUnicastResponseToMulticast : NotConfigured
NotifyOnListen                  : False
EnableStealthModeForIPsec       : NotConfigured
LogFileName                     : %systemroot%\system32\LogFiles\Firewall\pfirewall.log
LogMaxSizeKilobytes             : 4096
LogAllowed                      : False
LogBlocked                      : False
LogIgnored                      : NotConfigured
DisabledInterfaceAliases        : {NotConfigured}

OSの再起動

最後に、OSを再起動し、これまでの設定を反映させる。

PS C:\Users\Administrator> Restart-Computer