#author("2020-09-15T23:13:21+09:00","default:ryuichi","ryuichi")
#author("2020-09-15T23:14:32+09:00","default:ryuichi","ryuichi")
* リモート接続の有効化 [#c87a34c2]
** (サーバ側)リモート接続の有効化 [#i4e0e85b]
PS C:\Windows\system32> Enable-PSRemoting
WinRM は要求を受信するように更新されました。
WinRM サービスの種類を正しく変更できました。
WinRM サービスが開始されました。
WinRM はリモート管理用に更新されました。
WinRM ファイアウォールの例外を有効にしました。
- Enable-PSRemotingコマンドレットを実行する。
- コマンドレットを実行すると、Set-WSManQuickConfigなど必要な処理がすべて行われる。
- WinRMサービスが起動され、ファイヤウォールの設定が変更され、WS-MANのためのポートが開かれる。
** (クライアント側)接続先サーバの追加 [#x09e5d97]
*** 追加 [#h2acd653]
PS> Set-Item wsman:\localhost\client\TrustedHosts -Value 192.168.0.10 -Force
- 192.168.0.10が接続先のサーバ
*** 確認 [#q8dd1490]
PS> Get-Item WSMan:\localhost\Client\TrustedHosts
*** クリア [#fcae535a]
PS> Clear-Item WSMan:\localhost\Client\TrustedHosts
*** 参考 [#acf2e7de]
https://mstn.hateblo.jp/entry/2016/09/13/193124
** (クライアント側)リモート接続の実行 [#hfc7a17d]
PS> Enter-PSSession -ComputerName myremote-pc1 -Credential mydomain\administrator
** WinRMのポートを変更する [#y4386cba]
Winrm set winrm/config/listener?Address=*+Transport=HTTP@{Port="1234"}
** PowerShellリモーティングはドメインネットワークで行う [#e68c874f]
- PowerShellリモーティングでは、対象のPC群はActive Directoryで管理されていて、同じドメインネットワークに参加している前提になっている。
- ドメイン環境でなくともPowerShellリモーティングは可能だが、設定が複雑になり、セキュリティに問題が起きるかもしれない。詳しくは、help about_remote_troubleshooting を参考にする。