我们的环境中阻止了端口5985和5986,我需要备用端口
使用不同的方法执行Invoke
和Enter-PSSession
命令的解决方案
端口(如3389)。
winrm get winrm/config/client
的输出:
Client
NetworkDelayms = 5000
URLPrefix = wsman
AllowUnencrypted = false
Auth
Basic = true
Digest = true
Kerberos = true
Negotiate = true
Certificate = true
CredSSP = false
DefaultPorts
HTTP = 5985
HTTPS = 5986
TrustedHosts
错误:
get-wsmaninstance : The WinRM client received an unknown HTTP status code
from the remote WS-Management service.
At line:1 char:1
+ get-wsmaninstance -enumerate wmicimv2/win32_service -computername
sadcm0000078:8 ...
答案 0 :(得分:0)
事后才觉得这是一个足够的答案:
-Port
cmdlet上有-PSSession
个参数。您可以指定所需的端口,但是您需要配置端点以更改它正在侦听的端口。
PS C:\> Get-Help New-PSSession -Parameter Port
-Port <Int32>
Specifies the network port on the remote computer that is used for this connection. To connect to a remote
computer, the remote computer must be listening on the port that the connection uses. The default ports are 5985,
which is the WinRM port for HTTP, and 5986, which is the WinRM port for HTTPS.
Before using another port, you must configure the WinRM listener on the remote computer to listen at that port.
Use the following commands to configure the listener:
1. `winrm delete winrm/config/listener?Address=*+Transport=HTTP`
2. `winrm create winrm/config/listener?Address=*+Transport=HTTP @{Port="<port-number>"}`
Do not use the Port parameter unless you must. The port setting in the command applies to all computers or
sessions on which the command runs. An alternate port setting might prevent the command from running on all
computers.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false