Run a non-blocking process from PowerShell

Am I writing a powershell script that should push code into multiple git repositories at the same time?

Here's the script I still have:

param(
    [parameter(Mandatory=$true)]
    [string]$repoPath,
    [parameter(Mandatory=$true)]
    [array]$remoteRepos
)

pushd $repoPath
$remoteRepos | % { 
    #Want to exexcute this without blocking
    & git push $_ master --fore -v 
}
popd

This is how I execute the script:

gitdeploy.ps1 -repoPath c:\code\myrepo -remoteRepos repo1,repo2

How to execute & git push $_ master --fore -vin such a way that it does not block?

Decision

Thanks to @Jamey for the solution. I ran this command:

Start-Process "cmd.exe" "/c git push $_ master --force -v"
+5
source share
2 answers

You can also use start-process to start each click in an additional command window.

start-process -FilePath "git" -ArgumentList ("push", $_,  "master", "--fore", "-v") 
+4
source

Micah, you can use start-job to start in the background - http://technet.microsoft.com/en-us/library/dd347692.aspx

+2
source

All Articles