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

Roo*_*noy 5 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:\3PDInstallers\logs" }"
Run Code Online (Sandbox Code Playgroud)

我需要做的就是在远程机器上运行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
Run Code Online (Sandbox Code Playgroud)

更新:

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

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

Loï*_*HEL 3

这更像是一种解决方法,而不是答案,但是既然您能够使用 wmi,为什么不尝试用它创建远程进程呢?看看这里http://www.lazywinadmin.com/2011/06/powershell-launchstart-process-on.html?m=1

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