Cert attach to port for winRM use

source: https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-a-port-with-an-ssl-certificate

#check winrm is running 
winrm quickconfig
#see the attached certificates to http ports (command prompt)
netsh http show sslcert
#Delete the http listener for that port
netsh http delete sslcert ipport=0.0.0.0:5986

create certificate and attach to the port.

#powershell (create certificate)
$cert = New-SelfSignedCertificate -DnsName "160.104.101.50" -CertStoreLocation cert:\LocalMachine\My
#Powershell (Attach to port)
winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname=`"160.104.101.50`";CertificateThumbprint=`"$($cert.ThumbPrint)`"}"

(alternative) Add the certicate thumbprint to port.

#command prompt
netsh http add sslcert ipport=0.0.0.0:5986 certhash=9d411759dbf356ab402e0E63660ef433b613639d appid={bgdaa9bc-9a97-4z91-9bc5-eag4e59122g6}

===========================

To delete a listener created by the quickconfig command.

For an HTTP Listener:

winrm delete winrm/config/Listener?Address=*+Transport=HTTP

For an HTTPS Listener:

winrm delete winrm/config/Listener?Address=*+Transport=HTTPS

=========

Leave a comment