Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从本地使用powershell连接到远程服务器。输入PSSession不工作_Powershell_Powershell Remoting - Fatal编程技术网

如何从本地使用powershell连接到远程服务器。输入PSSession不工作

如何从本地使用powershell连接到远程服务器。输入PSSession不工作,powershell,powershell-remoting,Powershell,Powershell Remoting,我正在尝试使用本地powershell会话连接到远程计算机 为此,我尝试使用本地powershell输入PSSession或新建PSSessionComAndlet,如下所示: $session = New-PSSession -ConnectionUri 'http://testserverUri.dom/PowerShell' 但我总是遇到以下例外情况 New-PSSession : [testserveruri.dom] Connecting to remote server apdv0

我正在尝试使用本地powershell会话连接到远程计算机

为此,我尝试使用本地powershell
输入PSSession
新建PSSession
ComAndlet,如下所示:

$session = New-PSSession -ConnectionUri 'http://testserverUri.dom/PowerShell'
但我总是遇到以下例外情况

New-PSSession : [testserveruri.dom] Connecting to remote server apdv0710.forest7.dom failed with the following
error message : The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was
not available. This is usually returned by a HTTP server that does not support the WS-Management protocol. For more
information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $session = New-PSSession -ConnectionUri 'http://testserverUri.dom/ ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
   gTransportException
    + FullyQualifiedErrorId : URLNotAvailable,PSSessionOpenFailed
我还使用了其他变体:

Enter-PSSession -Authentication Kerberos -ConnectionUri 'http://testserveruri.dom/PowerShell' -Cred $credential
Enter-PSSession : Connecting to remote server apdv0710.forest7.dom failed with the following error message : The WinRM
client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is
usually returned by a HTTP server that does not support the WS-Management protocol. For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $session = Enter-PSSession -Authentication Kerberos -ConnectionUri 'h ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (http://testserveruri.dom/PowerShell:Uri) [Enter-PSSession], PSRemot
   ingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
在大多数情况下,我会遇到第一个例外

New-PSSession : [testserveruri.dom] Connecting to remote server apdv0710.forest7.dom failed with the following
error message : The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was
not available. This is usually returned by a HTTP server that does not support the WS-Management protocol. For more
information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $session = New-PSSession -ConnectionUri 'http://testserverUri.dom/ ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
   gTransportException
    + FullyQualifiedErrorId : URLNotAvailable,PSSessionOpenFailed
当我使用C#打开运行空间并为WSManConnectionInfo对象提供远程服务器PowerShell url时,也会发生同样的异常

关于winrm命令,我已经做了很多工作,但这并不能真正解决问题。
如何解决这个问题?

我只提供了计算机名,Kerberos作为身份验证机制,另外还有包含用户名和密码的凭证对象,这对我很有效

New-PSSession -Authentication Kerberos -Computer 'apdv004s' -Cred $credential 

同样的用法适用于
Enter-PSSession

Enter-PSSession正在工作。您发布的错误抱怨WinRM的配置。服务器是如何配置的?输入PSSession可以很好地用于localhost。但我想连接远程服务器,所有这些问题都是在远程服务器上打开运行空间/会话时出现的。您可以看到我提供的远程服务器urlBTW这是一个100%的管理问题,应该发布在
serverfault.com
Enter-PSSession也适用于远程会话。我用它就是为了这个。您让人们猜测远程服务器是如何配置的。你试过用谷歌搜索那个错误消息吗?远程计算机的操作系统版本是什么?serverfault.comNew-pssession,然后输入pssession。