Enter-PSSession開啓遠程PS會話失敗

前言:shell

Powershell能夠設置容許遠程登錄,操做遠程服務器,具體設置請參考其餘博客,下面主要解釋PS報錯:服務器

PS C:\Windows\system32> Enter-PSSession -ComputerName xxxx.xxxx.xxx.xx -Credential $cred
Enter-PSSession : 鏈接到遠程服務器 xxxx.xxxx.xxx.xx 失敗,並顯示如下錯誤消息: WinRM 沒法完成該操做。 請驗證指定的計算機名稱
有效,能夠經過網絡訪問該計算機,以及啓用了 WinRM 服務的防火牆例外並容許今後計算機中進行訪問。 默認狀況下,公用配置文件
的 WinRM 防火牆例外僅限訪問同一本地子網中的遠程計算機。 有關詳細信息,請參閱 about_Remote_Troubleshooting 幫助主題。
所在位置 行:1 字符: 1
+ Enter-PSSession -ComputerName xxxx.xxxx.xxx.xx -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (xxxx.xxxx.xxx.xx:String) [Enter-PSSession],PSRemotingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

從報錯能夠看出WinRM模式僅容許同一本地子網的遠程計算機訪問,在相同網關的另外一臺VM用Powershell測試:網絡

PS C:\Windows\system32> Enter-PSSession -ComputerName xxxx.xx.xxx.xx -Credential $cred
[xxxx.xx.xxx.xx]: PS C:\Users\Administrator\Documents>

發如今同一個網段能夠正常訪問,猜想是防火牆限制了不一樣網段的WinRM的鏈接,關閉防火牆後再測試原有報錯鏈接,能夠成功,猜想成立。測試

開啓防火牆WinRM端口,開放給全部網絡,新建入站規則spa

開發WinRM端口5985:code

最後再測試一下鏈接,發現能夠成功登錄,問題解決blog

相關文章
相關標籤/搜索