执行远程 PowerShell 脚本时出现错误。在我的本地机器上,我正在运行一个 PowerShell 脚本,该脚本Invoke-Command用于cd进入远程 Amazon Windows Server 实例上的目录,然后Invoke-Command执行位于该服务器实例上的脚本。服务器上的脚本正在尝试从 GitHub git clone 存储库。我可以在服务器脚本中成功执行诸如“ls”甚至“git --version”之类的操作。但是git clone,git pull等会导致以下错误:
克隆到 'MyRepo'... + CategoryInfo : NotSpecified: (克隆到 'MyRepo'...:String) [], RemoteException +fullyQualifiedErrorId : NativeCommandError
这是我第一次使用 PowerShell 或 Windows Server。任何人都可以就这个问题提供一些指导。
客户端脚本:
$s = new-pssession -computername $server -credential $user
invoke-command -session $s -scriptblock { cd C:\Repos; ls }
invoke-command -session $s -scriptblock { param ($repo, $branch) & '.\clone.ps1' -repository $repo -branch $branch} -ArgumentList $repository, $branch
exit-pssession
Run Code Online (Sandbox Code Playgroud)
服务器脚本: …