Like you can use SSH to execute remote command on a remote Linux machine and you can also execute remote PowerShell on a target Windows Server.
To enable it with a self-signed certificate, execute the following command: (Execute it on your server)
> Get-ChildItem WSMan:\Localhost\listener | Remove-Item -Recurse # Remove old listeners
> $Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName machine.contoso.com # Create a certificate. (Replace it with your own domain)
> New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint –Force # Enable HTTPS remoting
After configuring your listening address, you can connect to your server via PowerShell: (Execute it on your local machine)
> $sessionOptions = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck # Skip CA Check because your certification is self signed.
> Enter-PSSession -ComputerName machine.contoso.com -UseSSL -Port 5986 -SessionOption $sessionOptions –Credential Domain\UserName
And you will be asked for password:
And just connect successfully:
If you can't connect to your server, it might because the port was blocked. Unblock it with PowerShell: (Execute it on your server)
> New-NetFirewallRule -Displayname 'WinRM - Powershell remoting HTTPS-In' -Name 'WinRM - Powershell remoting HTTPS-In' -Profile Any -LocalPort 5986 -Protocol TCP
However, WinRM is limited to windows-to-windows connection, and OpenSSH works for any-to-any connection.
Also very easy to install.