From 104e4a99616622f0b510d9ca7b01934304445c50 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Tue, 7 Oct 2025 10:01:21 +1000 Subject: [PATCH] Update WinRM Listener Code Updates the examples used to create a HTTP or HTTPS WinRM listener to be compatible with both Windows PowerShell 5.1 and PowerShell 7.x. The `New-WSManInstance` only worked for WinPS and not for PS 7.x. --- docs/docsite/rst/os_guide/windows_winrm.rst | 54 +++++++++------------ 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/docs/docsite/rst/os_guide/windows_winrm.rst b/docs/docsite/rst/os_guide/windows_winrm.rst index 5d4bf25eda1..f3de4f45c11 100644 --- a/docs/docsite/rst/os_guide/windows_winrm.rst +++ b/docs/docsite/rst/os_guide/windows_winrm.rst @@ -90,17 +90,15 @@ To also add a HTTPS listener with a self signed certificate we can run the follo # Create HTTPS listener $httpsParams = @{ - ResourceURI = 'winrm/config/listener' - SelectorSet = @{ - Transport = "HTTPS" - Address = "*" - } - ValueSet = @{ - CertificateThumbprint = $cert.Thumbprint - Enabled = $true - } + Path = 'WSMan:\localhost\Listener' + Address = '*' + CertificateThumbprint = $cert.Thumbprint + Enabled = $true + Port = 5986 + Transport = 'HTTPS' + Force = $true } - New-WSManInstance @httpsParams + New-Item @httpsParams # Opens port 5986 for all profiles $firewallParams = @{ @@ -175,35 +173,29 @@ Creating a HTTP listener can be done through the ``Enable-PSRemoting`` cmdlet bu .. code-block:: powershell $listenerParams = @{ - ResourceURI = 'winrm/config/listener' - SelectorSet = @{ - Transport = "HTTP" - Address = "*" - } - ValueSet = @{ - Enabled = $true - Port = 5985 - } + Path = 'WSMan:\localhost\Listener' + Address = '*' + Enabled = $true + Port = 5985 + Transport = 'HTTP' + Force = $true } - New-WSManInstance @listenerParams + New-Item @listenerParams Creating a HTTPS listener is similar but the ``Port`` is now ``5986`` and the ``CertificateThumbprint`` value must be set. The certificate can either be a self signed certificate or a certificate from a certificate authority. How to generate a certificate is outside the scope of this section. .. code-block:: powershell $listenerParams = @{ - ResourceURI = 'winrm/config/listener' - SelectorSet = @{ - Transport = "HTTPS" - Address = "*" - } - ValueSet = @{ - CertificateThumbprint = 'E6CDAA82EEAF2ECE8546E05DB7F3E01AA47D76CE' - Enabled = $true - Port = 5986 - } + Path = 'WSMan:\localhost\Listener' + Address = '*' + CertificateThumbprint = 'E6CDAA82EEAF2ECE8546E05DB7F3E01AA47D76CE' + Enabled = $true + Port = 5986 + Transport = 'HTTPS' + Force = $true } - New-WSManInstance @listenerParams + New-Item @listenerParams The ``CertificateThumbprint`` value must be set to the thumbprint of a certificate that is installed in the ``LocalMachine\My`` certificate store.