Remote Powershwll
リモートPowershell
サーバ設定, 管理者
Enable-PSRemoting
Client設定、管理者
net start WinRM
Set-Item WSMan:\localhost\Client\TrustedHosts -Value [ip]
[ip] はサーバのIP
client 使用方法、一般ユーザー
enter-PSSession -ComputerName [ip] -Credential [user]
[user]はサーバのログイン user ID
パスワード入力が必要
適当なコマンド、ipconfig等
Exit-PSSession
補足
使用ポートは、TCP 5985
client でtrusted host設定する事には違和感があるが、仕様なので。
パスワード入力があるため、スクリプト処理が難しい。
また、リモートでスクリプト実行を一つのコマンドでできない点が不便。
without password
$ppw = "plain_password" $user = "login_id" $ip = "Server ip" $epw = ConvertTo-SecureString $ppw -AsPlainText -Force $cred= New-Object System.Management.Automation.PSCredential ($user, $epw ) enter-PSSession -ComputerName $ip -Credential $cred
Linux client
Here's a workaround I used, YMMV. To run the PowerShell docker container on CentOS that should allow you to Enter-PSSession into Windows computers run the following docker run -it mcr.microsoft.com/powershell:7.0.0-preview.6-centos-7 or docker run -it mcr.microsoft.com/powershell:preview (which should work on any platform), this will start up a docker container interactively and will give you a PowerShell command line at the end, which suited my needs (I did have to add -Authentication Negotiate on the Enter-PSSession though). When you exit the PowerShell terminal the docker container will stop and you'll need to rerun that command. Keep in mind it is a container so be mindful when attempting to use files. If a container doesn't suit your needs, read on.