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
I just finished reading your blog post on enabling PowerShell remoting for Windows Server machines. I appreciate the detailed and step-by-step instructions provided in your article. The core idea of using PowerShell for remote execution on Windows Server machines is quite helpful, and I believe it will benefit many users who are looking to manage their servers remotely.
One of the key highlights of your post is the use of a self-signed certificate to enable HTTPS remoting. This adds an extra layer of security to the process, and your instructions on how to create and configure the certificate are clear and easy to follow. Additionally, the screenshots you included help to visualize the process and make it more accessible for readers.
However, there are a few areas where the article could be improved. Firstly, it would be helpful to provide some background information on PowerShell remoting and its benefits, especially for readers who may not be familiar with the concept. This would help to set the context and make the content more engaging.
Secondly, while your instructions are generally clear, there are a few instances where you could provide more explanation. For example, when discussing the command to unblock the port, it would be helpful to explain the purpose of each parameter used in the command. This would make it easier for readers to understand and customize the command for their own needs.
Lastly, it would be beneficial to include a troubleshooting section at the end of the article. This could cover common issues that users may encounter when setting up PowerShell remoting, such as firewall settings, network configurations, or certificate issues. Providing solutions or guidance on how to resolve these issues would make your article even more valuable to readers.
Overall, I found your blog post to be informative and useful. With some minor improvements, it has the potential to become an excellent resource for users looking to enable PowerShell remoting on their Windows Server machines. Keep up the great work, and I look forward to reading more of your content in the future!
However, WinRM is limited to windows-to-windows connection, and OpenSSH works for any-to-any connection.
Also very easy to install.