PowerShell - 在远程机器上执行脚本给出错误 [英] PowerShell - executing a script on a remote machine giving error

查看:55
本文介绍了PowerShell - 在远程机器上执行脚本给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容对我不起作用 -

This following is not working for me -

%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.我假设运行脚本的用户需要访问远程机器.

all I need to do is run msiexec on a remote machine. I am assuming that the user running the script will have required access to the remote machine.

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

The script doesn't work even when the Computername points to the local computer (and running msiexec with the same logged in user works fine, so it doesn't look like a permissions issue) - I have ensured that the WinRM service is running, and I also disabled to firewall to check whether that is the cause of issue, but no luck so far. What am I missing here?

这是完整的错误,但它几乎列出了所有可能性 -

This is the full error but it pretty much lists all possibilities -

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 时,它会弹出一个登录窗口以获取我的密码,然后在输入密码时出现以下错误 - 用户确实具有管理员访问权限,所以我不知道出了什么问题.

When I use -Credentials with just the username, it pops up a login window to get my password and then on entering it, gives the following error - the user does have admin access so I don't know what's wrong.

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

[spider_lt_86] Connecting to remote server failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (:) [], PSRemotingTransportException + FullyQualifiedErrorId : PSSessionStateBroken

推荐答案

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

This is more a workaround than an answer but as you re able to use wmi why not try to create the remote process with it? Have a look here http://www.lazywinadmin.com/2011/06/powershell-launchstart-process-on.html?m=1

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

After comments exchange, the problem is that you had not provide a credential with administrative privilege for the remote host.

这篇关于PowerShell - 在远程机器上执行脚本给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆