Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.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 - Fatal编程技术网

Powershell-如何运行位于另一台计算机上的脚本?

Powershell-如何运行位于另一台计算机上的脚本?,powershell,Powershell,谁能给我一些提示吗?我被这个问题困住了 我已在以下位置开发了PowerShell脚本: \\\ComputerNameA.xxx.xxx.local\d\xxx\script.ps1 此脚本需要4个参数才能工作。我需要从另一台计算机上运行该脚本 我试过: Invoke-Command -ComputerName ComputerNameA -FilePath \\\ComputerNameA.xxx.xxx.local\d\xxx\script.ps1 -Argu

谁能给我一些提示吗?我被这个问题困住了

我已在以下位置开发了PowerShell脚本:

\\\ComputerNameA.xxx.xxx.local\d\xxx\script.ps1
此脚本需要4个参数才能工作。我需要从另一台计算机上运行该脚本

我试过:

Invoke-Command -ComputerName ComputerNameA 
      -FilePath \\\ComputerNameA.xxx.xxx.local\d\xxx\script.ps1  
      -ArgumentList {-arg0 string -arg1 string -arg2 string -arg3 string}
如有任何提示,将不胜感激

更新: 至于回答我原来的问题,我认为答案是: 调用命令-ComputerName ComputerNameA-Credential$cred -FilePath\\ComputerNameA.xxx.xxx.local\d\xxx\script.ps1
-参数列表{-arg0字符串-arg1字符串-arg2字符串-arg3字符串}


现在,新的问题是,即使存在凭据,我也会遇到拒绝访问错误(即,我设置了一个新的用户帐户-abcd并将密码设置为abcd)

您可以尝试在脚本所在的位置安装ssh服务器,然后使用putty for windows进行连接

然后执行参考

从其他系统运行脚本时出现了什么错误谢谢Jawad。我解决了前面的问题。我需要使用“”作为包含空格的文件夹名称。新的错误消息是:连接到远程服务器ComputerNameA失败,错误消息如下:访问被拒绝。您的invoke命令需要凭据才能访问另一台计算机。您需要域级访问才能运行它,或者使用pssession设置凭据,然后使用它们。或者,您可以使用username参数在命令中设置它们。谢谢你,罗伯特。我在ComputerNameA中设置了一个新用户帐户,使该用户成为“用户”和“PS作业用户”的成员。并在invoke命令中使用-credential,但仍然失败:AccessDenied,PSSessionStateBrokenThank you Bevin NIno。ComputerNameA实际上是一个服务器,我不允许安装任何东西。即使SSH在ComupterNameA中可用,我想我也不能使用SSH,因为这需要在脚本中提供用户名和密码。如果您不想包含用户名和密码,请使用certificateThank,谢谢。我最终尝试使用-凭证