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.

POWERSHELL:
  1. # Installs git for Windows via PowerShell
  2. #
  3. # Sample usage:
  4. #
  5. #  Install git:
  6. #    PS> install-git
  7. #
  8. # Adam Kahtava - http://adam.kahtava.com/ - MIT Licensed
  9.  
  10. function global:install-git {
  11.   install-file 'http://msysgit.googlecode.com/files/Git-1.6.4-preview20090730.exe'
  12. }
  13.  
  14. function global:install-file([string] $urlPath) {
  15.   $filename = download-file($urlPath)
  16.   invoke-item $filename
  17. }
  18.  
  19. function global:download-file([string] $urlPath) {
  20.   $urlSplit = $urlPath.split('/')
  21.   $filename = (Resolve-Path .).ToString() + '' + $urlSplit[$urlSplit.length - 1]
  22.   $webclient = New-Object "System.Net.WebClient"
  23.   $webclient.DownloadFile($urlPath, $filename)
  24.   return $filename
  25. }

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.