繁体   English   中英

PowerShell-在提供错误的远程计算机上执行脚本

[英]PowerShell - executing a script on a remote machine giving error

以下追踪不适用于我-

%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

更新:

当我仅使用用户名使用-Credentials时,它会弹出一个登录窗口以获取我的密码,然后在输入密码时出现以下错误-用户确实具有管理员权限,所以我不知道出了什么问题。

[spider_lt_86]连接到远程服务器失败,并显示以下错误消息:访问被拒绝。 有关更多信息,请参见about_Remote_Troubleshooting帮助主题。 + CategoryInfo:OpenError:(:)[],PSRemotingTransportException + FullyQualifiedErrorId:PSSessionStateBroken

这不是解决方案,而是答案,但是您能够使用wmi为何不尝试使用它创建远程进程? 在这里看看http://www.lazywinadmin.com/2011/06/powershell-launchstart-process-on.html?m=1

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

您是否在计算机上设置了TrustedHosts,以允许您连接到其他计算机?

在您要远程启动的计算机上运行此命令。

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

一件事很清楚,错误消息“未找到网络路径”没有表明潜在问题是什么。 我在Microsoft论坛上看到了一篇帖子,受访者说该帖子曾经有用,现在却没有。 那是我发现自己的地方。 我确认可以ping通并且可以查看共享,因此我知道网络部分可以正常工作。 我重新启动了源服务器,但这似乎没有帮助。 重新启动目标服务器后 ,WinRM错误消失了,一切再次开始正常工作。 目前尚不清楚服务是否关闭或行为异常,或者是否发生了不太明显的事情。 重新启动后,我又遇到了一次失败(大约20次尝试),但是随机失败在我们的环境中并不少见。

我会把它抛在后面,以防它对别人有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM