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-在远程计算机上执行脚本时出错_Powershell_Powershell Remoting - Fatal编程技术网

PowerShell-在远程计算机上执行脚本时出错

PowerShell-在远程计算机上执行脚本时出错,powershell,powershell-remoting,Powershell,Powershell Remoting,以下内容不适用于我- %WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Noninteractive -command "& Invoke-Command -ComputerName "Spider_LT_86" -ScriptBlock { msiexec.exe /i "D:\3PDInstallers\ETLBackgroundWorkerSetup.msi" /qn /l*vx "D:\3PDI

以下内容不适用于我-

%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Noninteractive -command "& Invoke-Command -ComputerName "Spider_LT_86" -ScriptBlock { msiexec.exe /i "D:\3PDInstallers\ETLBackgroundWorkerSetup.msi" /qn /l*vx "D:\3PDInstallers\logs" }"
我需要做的就是在远程机器上运行msiexec。我假设运行脚本的用户将具有访问远程计算机所需的权限

即使Computername指向本地计算机,脚本也不起作用(并且使用同一个登录用户运行msiexec工作正常,因此看起来不像是权限问题)-我已确保WinRM服务正在运行,并且我还禁用了防火墙以检查这是否是问题的原因,但目前为止运气不佳。我错过了什么

这是全部错误,但它几乎列出了所有可能性-

Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occured while using
Kerberos authentication: The network path was not found.
Possible causes are:
  -The user name or password specified are invalid.
  -Kerberos is used when no authentication method and no user name are specified.
  -Kerberos accepts domain user names, but not local user names.
  -The Service Principal Name (SPN) for the remote computer name and port does not exist.
  -The client and remote computers are in different domains and there is no trust between the two domains.
After checking for the above issues, try the following:
  -Check the Event Viewer for events related to authentication.
  -Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use HTTPS transport.
Note that computers in the TrustedHosts list might not be authenticated.
   -For more information about WinRM configuration, run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting He
lp topic.
    + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException
    + FullyQualifiedErrorId : PSSessionStateBroken
更新:

当我只使用用户名使用-凭据时,它会弹出一个登录窗口来获取我的密码,然后在输入密码时,会出现以下错误-用户具有管理员访问权限,因此我不知道出了什么问题

[spider_lt_86]连接到远程服务器失败,错误消息如下:访问被拒绝。有关更多信息,请参阅关于远程故障排除帮助主题。 +CategoryInfo:OpenError:(:)[],PSRemotingTransportException
+FullyQualifiedErrorId:PSSessionStateBreaked

这与其说是一个答案,不如说是一个解决办法,但既然您能够使用wmi,为什么不尝试用它创建远程进程呢?看看这里


交换评论后,问题是您没有为远程主机提供具有管理权限的凭据。

您是否已将计算机上的受信任主机设置为允许您连接到其他计算机

在您尝试远程访问的计算机上运行此操作

Set-Item  wsman::localhost\client\TrustedHosts *  
Restart-Service WinRm

有一点很清楚,错误消息“未找到网络路径”没有指出根本问题是什么。我在一家报纸上看到一篇帖子,其中一位受访者表示,这篇帖子过去是有效的,但现在没有了。这就是我发现自己的地方。我验证了我可以ping,并且可以查看网络共享,因此我知道网络部分功能正常。我重新启动了源服务器,这似乎没有帮助。一旦我重新启动了目标服务器,WinRM错误就消失了,一切又开始工作了。目前尚不清楚某项服务是否出现故障或行为不端,或者是否存在不太明显的问题。重启后,我又遇到了一次失败(大约20次尝试中),但随机失败在我们的环境中并不少见


我会留下这个,以防万一它对其他人有帮助。

你能使用enter-pssession computername然后调用你的msiexec命令吗?啊,不行。。那也不行。连接自身(进入pssession)似乎是个问题。同样的错误,即使我尝试连接到当前计算机时也是如此。尝试在远程主机上执行enable psremoting-force将-Credential“Username”添加到命令时会发生什么情况?您的帐户可能不是远程amdinistrators组的成员,您应该在此处查看: