I would like to install GIT if it's not installed and then use git clone using PowerShell.
My first attempt looks like this:
try {
git --version | Out-Null
Write-Host "GIT is already installed."
} catch [System.Management.Automation.CommandNotFoundException]{
Write-Host "GIT ist not installed."
Write-Host "Installing..."
& gitsetup.exe /VERYSILENT /PathOption=CmdTools | Out-Null
}
git clone https://github.com/username/repository
I get a command not found error when it gets to git clone, because GIT has not finished installing.
Is there a good way to solve this problem?