use*_*777 6 windows powershell git
执行远程 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)
服务器脚本:
param([string]$repository = "repository", [string]$branch = "branch")
git --version
start-process -FilePath git -ArgumentList ("clone", "-b $branch https://github.com/MyGithub/$repository.git") -Wait
Run Code Online (Sandbox Code Playgroud)
我已将服务器脚本更改为使用启动进程,并且不再抛出异常。它创建新的存储库目录和 .git 目录,但不写入 github 存储库中的任何文件。这闻起来像是权限问题。再次手动调用脚本(远程桌面进入亚马逊盒子并从 powershell 执行它)就像一个魅力。
| 归档时间: |
|
| 查看次数: |
8903 次 |
| 最近记录: |