自宅のPCからAmazon EC2のWindows ServerインスタンスにPSRemotingする方法

AMIのWindows Server 2016 Baseイメージから作成した場合には、デフォルトでWinRM/PSRemotingが有効になっている(TODO: verify)。

EC2側で5985番ポートを開ける。

http://stackoverflow.com/a/13284313/6583019

初回のみ以下を自宅のPC上で実行する。

set-item WSMan:\localhost\Client\TrustedHosts -Value * -Force
set-item WSMan:\localhost\Shell\MaxMemoryPerShellMB -Value 0 -Force
Enable-PSRemoting
Set-ExecutionPolicy unrestricted

つなぐには、

$cred = Get-Credential
Enter-PSSession (EC2インスタンスのIPv4アドレス) -Credential $cred