Home > .NET, PowerShell > Install Git On Windows With PowerShell

Install Git On Windows With PowerShell

I like Git and here's a PowerShell script that I use to download and install Git on my Windows based development machines.

# Installs git for Windows via PowerShell
#
# Sample usage:
#
#  Install git:
#    PS> install-git
#
# Adam Kahtava - http://adam.kahtava.com/ - MIT Licensed

function global:install-git {
  install-file 'http://msysgit.googlecode.com/files/Git-1.6.4-preview20090730.exe'
}

function global:install-file([string] $urlPath) {
  $filename = download-file($urlPath)
  invoke-item $filename
}

function global:download-file([string] $urlPath) {
  $urlSplit = $urlPath.split('/')
  $filename = (Resolve-Path .).ToString() + '' + $urlSplit[$urlSplit.length - 1]
  $webclient = New-Object "System.Net.WebClient"
  $webclient.DownloadFile($urlPath, $filename)
  return $filename
}

Not familiar with Git? Then head over to the best online Git resource available.

You can find more of my PowerShell development scripts here.

Author: Adam Kahtava Categories: .NET, PowerShell Tags:
  1. No comments yet.
  1. No trackbacks yet.