Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am getting an error while executing a remote PowerShell script. From my local machine I am running a PowerShell script that uses Invoke-Command to cd into a directory on a remote Amazon Windows Server instance, and a subsequent Invoke-Command to execute script that lives on that server instance. The script on the server is trying to git clone a repository from GitHub. I can successfully do things in the server script like "ls" or even "git --version". However git clone, git pull, etc. result in the following error:

Cloning into 'MyRepo'... + CategoryInfo : NotSpecified: (Cloning into 'MyRepo'...:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError

This is my first time using PowerShell or a Windows Server. Can anyone provide some direction on this problem.

The client script:

$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

The server script:

param([string]$repository = "repository", [string]$branch = "branch")
git --version
start-process -FilePath git -ArgumentList ("clone", "-b $branch    https://github.com/MyGithub/$repository.git") -Wait 

I've changed the server script to use start process and it is no longer throwing the exception. It creates the new repository directory and the .git directory but doesn't write any of the files from the github repository. This smells like a permissions issue. Once again invoking the script manually (remote desktop into the amazon box and execute it from powershell) works like a charm.

share|improve this question
    
Posting your powershell script could help us... –  krisFR Jan 8 at 18:28

2 Answers 2

I see this 'error' as well when using Powershell ISE and Git locally. It isn't actually an error; rather, Powershell ISE is incorrectly interpreting Git's console output. If you try the console-based Powershell, you should notice that there is no error information displayed. It seems that this is just a peculiarity of Powershell ISE (and possibly other Powershell hosts that don't handle console application output well).

share|improve this answer

You may be running into Double Hop problem explained here: http://blogs.msdn.com/b/clustering/archive/2009/06/25/9803001.aspx

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.