Skip to content

Commit 3ecd3e5

Browse files
authored
Update WinRM Listener Code (#3101)
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.
1 parent 602e65f commit 3ecd3e5

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

docs/docsite/rst/os_guide/windows_winrm.rst

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,15 @@ To also add a HTTPS listener with a self signed certificate we can run the follo
9090
9191
# Create HTTPS listener
9292
$httpsParams = @{
93-
ResourceURI = 'winrm/config/listener'
94-
SelectorSet = @{
95-
Transport = "HTTPS"
96-
Address = "*"
97-
}
98-
ValueSet = @{
99-
CertificateThumbprint = $cert.Thumbprint
100-
Enabled = $true
101-
}
93+
Path = 'WSMan:\localhost\Listener'
94+
Address = '*'
95+
CertificateThumbprint = $cert.Thumbprint
96+
Enabled = $true
97+
Port = 5986
98+
Transport = 'HTTPS'
99+
Force = $true
102100
}
103-
New-WSManInstance @httpsParams
101+
New-Item @httpsParams
104102
105103
# Opens port 5986 for all profiles
106104
$firewallParams = @{
@@ -175,35 +173,29 @@ Creating a HTTP listener can be done through the ``Enable-PSRemoting`` cmdlet bu
175173
.. code-block:: powershell
176174
177175
$listenerParams = @{
178-
ResourceURI = 'winrm/config/listener'
179-
SelectorSet = @{
180-
Transport = "HTTP"
181-
Address = "*"
182-
}
183-
ValueSet = @{
184-
Enabled = $true
185-
Port = 5985
186-
}
176+
Path = 'WSMan:\localhost\Listener'
177+
Address = '*'
178+
Enabled = $true
179+
Port = 5985
180+
Transport = 'HTTP'
181+
Force = $true
187182
}
188-
New-WSManInstance @listenerParams
183+
New-Item @listenerParams
189184
190185
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.
191186

192187
.. code-block:: powershell
193188
194189
$listenerParams = @{
195-
ResourceURI = 'winrm/config/listener'
196-
SelectorSet = @{
197-
Transport = "HTTPS"
198-
Address = "*"
199-
}
200-
ValueSet = @{
201-
CertificateThumbprint = 'E6CDAA82EEAF2ECE8546E05DB7F3E01AA47D76CE'
202-
Enabled = $true
203-
Port = 5986
204-
}
190+
Path = 'WSMan:\localhost\Listener'
191+
Address = '*'
192+
CertificateThumbprint = 'E6CDAA82EEAF2ECE8546E05DB7F3E01AA47D76CE'
193+
Enabled = $true
194+
Port = 5986
195+
Transport = 'HTTPS'
196+
Force = $true
205197
}
206-
New-WSManInstance @listenerParams
198+
New-Item @listenerParams
207199
208200
The ``CertificateThumbprint`` value must be set to the thumbprint of a certificate that is installed in the ``LocalMachine\My`` certificate store.
209201

0 commit comments

Comments
 (0)