New-PSSession does not work locally

*爱你&永不变心* 提交于 2019-12-05 11:34:39

By process of elimination, we can rule out firewall as an issue, as you are only connecting to the loopback address (127.0.0.1). We can also rule out WinRM configuration which looks fine.

The error message suggests that TCP connection to http://localhost:8173/WSMAN is actually successful, but fault occurs while establishing PS session.

This points to Microsoft.PowerShell session configuration.

Looks like there is a discrepancy in the permissions you see when looking at

Set-PSSessionConfiguration -Name Microsoft.PowerShell -showSecurityDescriptorUI 

and the permission actually assigned to Microsoft.PowerShell. The output of

Get-PSSessionConfiguration microsoft.powershell | fl *

should have the "SecurityDescriptorSddl" and "Permission" proprieties listed. Like this:

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

Try removing and reassigning these permissions.

EDIT:

Based on the information you have provided this is not the main problem. I have also noticed that you have a non standard "RootSDDL" in WinRM service settings.

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)

by default this should be

RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GWGX;;;WD)

I have recreated this on the test VM and Remoting still works. So I had another look at your WinRM configuration ...

Solution

Your problem is this line

MaxEnvelopeSizekb = 1039440

By setting this value I can replicate the issue you have. I would suggest to set this to something more reasonable, or to default.

winrm set winrm/config '@{MaxEnvelopeSizekb="150"}'

Will fix your problem.

In a "strict" IPV4 environent, we had the same Problem as well.

The reason was: WinRM (and other services) seem to use the IpV6-Loopback-Address even if ipv6 is disabled everywhere. (Which is no Problem, except with WinRM)

Hence, if there is no WinRM-Listener for the IPV6-Loopback Adress - you can't connect to localhost, even if WinRM is working from a remote-host.

Brendan

setting the following worked for me after I upgraded to computers from win 10 1607 to 1708

the update changed the following reg key to 1, and setting it back to 0 worked for me

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
FilterAdministratorToken=dword:0
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!