First, create the self-sighed certificate using the New-SelfSignedCertificate cmdlet.
Next, configure the WinRM listener to use the certificate that you created by specifying its thumbprint (place all on one line).
Notice the single quotes in the command. This allows the command to be run from PowerShell.
Lastly, make sure that the WinRM traffic is allowed through the firewall. Create a rule with the name “Windows Remote Management (HTTPS-In)” that allows TCP/5986 through.
To connect to the host from another client use the following code:
The following PowerShell script will configure the WinRM service create the HTTPS WinRM listener with a self-signed certificate and create a firewall rule: