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

时间:2020-06-23 03:40:31

标签: powershell

有人可以给我一些提示吗?我陷入了这个问题。

我在以下位置开发了一个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}

任何提示将不胜感激。

更新: 至于回答我的原始问题,我认为答案是: 调用命令-计算机名计算机名A-凭据$ cred -FilePath \\ ComputerNameA.xxx.xxx.local \ d \ xxx \ script.ps1
-ArgumentList {-arg0字符串-arg1字符串-arg2字符串-arg3字符串}

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

1 个答案:

答案 0 :(得分:-1)

您可以尝试在脚本所在的位置安装ssh服务器,然后使用用于Windows的腻子进行连接
然后执行参考this