我正在尝试使用连接到localhost New-PSSession.
我有
使用配置的WinRM
winrm quickconfig
Run Code Online (Sandbox Code Playgroud)启用PS Remoting
Enable-PSRemoting
Run Code Online (Sandbox Code Playgroud)添加了可信主机
Set-Item WSMan:\localhost\Client\TrustedHosts * -Force
Run Code Online (Sandbox Code Playgroud)防火墙上的8173端口上有入站规则.
产量winrm:
PS C:\> winrm get winrm/config/listener?Address=*+Transport=HTTP
Listener
Address = *
Transport = HTTP
Port = 8173
Hostname
Enabled = true
URLPrefix = wsman
CertificateThumbprint
Listening on = 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
我试图运行以下命令:
New-PSSession -ConnectionUri http://localhost:8173/WSMAN
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
[localhost] Processing data from remote server failed with the following error message:
Error with error code 14 occurred while calling method WSManPluginReceiveResult. For
more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed
Run Code Online (Sandbox Code Playgroud)
编辑:
我看到的唯一额外的事情是网络连接到public $ listenerport ="8173"winrmwinrm create winrm/config/Listener?Address =*+ Transport = HTTP" @{Port ="$ listenerport "}"
C:\>winrm get winrm/config
Config
MaxEnvelopeSizekb = 1039440
MaxTimeoutms = 60000
MaxBatchItems = 32000
MaxProviderRequests = 4294967295
Client
NetworkDelayms = 5000
URLPrefix = wsman
AllowUnencrypted = true
Auth
Basic = true
Digest = true
Kerberos = true
Negotiate = true
Certificate = true
CredSSP = false
DefaultPorts
HTTP = 8173
HTTPS = 5986
TrustedHosts = *
Service
RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;S-1-5-21-2458768215-3945602940-3262220185-1045)S:P(AU;FA;GA;;;WD)(AU;SA;GWGX;;;WD)
MaxConcurrentOperations = 4294967295
MaxConcurrentOperationsPerUser = 500
EnumerationTimeoutms = 60000
MaxConnections = 25
MaxPacketRetrievalTimeSeconds = 120
AllowUnencrypted = true
Auth
Basic = true
Kerberos = false
Negotiate = true
Certificate = true
CredSSP = false
CbtHardeningLevel = Relaxed
DefaultPorts
HTTP = 5985
HTTPS = 5986
IPv4Filter = *
IPv6Filter = *
EnableCompatibilityHttpListener = false
EnableCompatibilityHttpsListener = false
CertificateThumbprint
Winrs
AllowRemoteShellAccess = true
IdleTimeout = 180000
MaxConcurrentUsers = 5
MaxShellRunTime = 2147483647
MaxProcessesPerShell = 15
MaxMemoryPerShellMB = 150
MaxShellsPerUser = 5
PS C:\> Get-PSSessionConfiguration microsoft.powershell | fl *
xmlns : http://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
Name : Microsoft.PowerShell
Filename : %windir%\system32\pwrshplugin.dll
SDKVersion : 1
XmlRenderingType : text
lang : en-US
PSVersion : 2.0
ResourceUri : http://schemas.microsoft.com/powershell/Microsoft.PowerShell
SupportsOptions : true
ExactMatch : true
Capability : {Shell}
Permission :
Administrators group have permission as I see in the window popup (Set-PSSessionConfiguration -Name Microsoft.PowerShell -showSecurityDescriptorUI)
Run Code Online (Sandbox Code Playgroud)
编辑2: 
通过消除过程,我们可以排除防火墙问题,因为您只连接到环回地址 (127.0.0.1)。我们还可以排除看起来不错的 WinRM 配置。
该错误信息表明 TCP 连接http://localhost:8173/WSMAN实际上是成功的,但在建立 PS 会话时出现故障。
这指向 Microsoft.PowerShell 会话配置。
看起来您在查看时看到的权限存在差异
Set-PSSessionConfiguration -Name Microsoft.PowerShell -showSecurityDescriptorUI
Run Code Online (Sandbox Code Playgroud)
以及实际分配给 Microsoft.PowerShell 的权限。的输出
Get-PSSessionConfiguration microsoft.powershell | fl *
Run Code Online (Sandbox Code Playgroud)
应该列出“SecurityDescriptorSddl”和“Permission”属性。像这样:
Name : microsoft.powershell
Filename : %windir%\system32\pwrshplugin.dll
SDKVersion : 1
XmlRenderingType : text
lang : en-US
PSVersion : 2.0
ResourceUri : http://schemas.microsoft.com/powershell/microsoft.powershell
SupportsOptions : true
Capability : {Shell}
xmlns : http://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
Uri : http://schemas.microsoft.com/powershell/microsoft.powershell
ExactMatch : true
SecurityDescriptorSddl : O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
Permission : BUILTIN\Administrators AccessAllowed
Run Code Online (Sandbox Code Playgroud)
尝试删除并重新分配这些权限。
编辑:
根据您提供的信息,这不是主要问题。我还注意到您在 WinRM 服务设置中有一个非标准的“RootSDDL”。
RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;S-1-5-21-2458768215-3945602940-3262220185-1045)(AU;SA;GWGX;;;WD)
Run Code Online (Sandbox Code Playgroud)
默认情况下,这应该是
RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GWGX;;;WD)
Run Code Online (Sandbox Code Playgroud)
我在测试虚拟机上重新创建了这个,远程处理仍然有效。所以我再看看你的 WinRM 配置......
解决方案
你的问题是这条线
MaxEnvelopeSizekb = 1039440
Run Code Online (Sandbox Code Playgroud)
通过设置此值,我可以复制您遇到的问题。我建议将其设置为更合理的值,或者设置为默认值。
winrm set winrm/config '@{MaxEnvelopeSizekb="150"}'
Run Code Online (Sandbox Code Playgroud)
会解决你的问题。
| 归档时间: |
|
| 查看次数: |
10286 次 |
| 最近记录: |