Powershell script to install Cygwin

I like having Cygwin installed on my machine, and since I always re-image, I needed a script to install Cygwin automatically.

function Install-Cygwin {
   param ( $TempCygDir="$env:temp\cygInstall" )
   if(!(Test-Path -Path $TempCygDir -PathType Container))
    {
       $null = New-Item -Type Directory -Path $TempCygDir -Force
    }
   $client = new-object System.Net.WebClient
   $client.DownloadFile("http://cygwin.com/setup.exe", "$TempCygDir\setup.exe" )
   Start-Process -wait -FilePath "$TempCygDir\setup.exe" -ArgumentList "-q -n -l $TempCygDir -s http://mirror.nyi.net/cygwin/ -R c:\Cygwin"
   Start-Process -wait -FilePath "$TempCygDir\setup.exe" -ArgumentList "-q -n -l $TempCygDir -s http://mirror.nyi.net/cygwin/ -R c:\Cygwin -P openssh"
}

This will download and install Cygwin and install the openssh package.

,

2 Responses to Powershell script to install Cygwin

  1. Eric Mann October 1, 2012 at 12:09 pm #

    A very useful little script. But you might want to unescape the " characters in your display. They make copy-pasting into PowerShell a bit of a hassle.

  2. jbmurphy October 1, 2012 at 12:32 pm #

    Done! Look right? WordPress messes with the quotes if I accidentally switch between HTML and Visual view. Thanks for taking the time to comment.