Quantcast
Channel: Software
Viewing all articles
Browse latest Browse all 10

Updating TortoiseSVN with PowerShell

$
0
0

I believe in two kinds of PC software: portable - so I just drop .exe in my tools folder and use it and software that automatically updates – Google Chrome is champion here.

Unfortunately TortoiseSVN is neither. It will tell me that is out of date, but then I have to jump through several loops (going to browser, searching for download site, downloading file,…) before it’s up to date.

Using a new cmdlet Invoke-WebRequest of PowerShell 3.0 that downloads and parses a HTML writing a script that downloads latest TortoiseSVN .msi is a breeze…

First, let’s get the page (I use VisualSVN not SourceForge, since it’s easier to parse).

$html = Invoke-WebRequest http://www.visualsvn.com/visualsvn/download/tortoisesvn/

Let’s find the link that points to 64-bit TortoiseSVN MSI, shall we? Easy in PS3! (mind .Links, where and select!)

$downloadUrl = $html.Links | where href -like "*tortoisesvn*-x64-*.msi" | select href

Now just download file to current folder and we are done.

 

Here is complete script:

function DownloadFile($downloadUrl)
{
    $filename = $downloadUrl.Substring($downloadUrl.LastIndexOf('/') + 1)
    $localFilename = (Resolve-Path ".").Path + '\' + $filename
    $webResponse = Invoke-WebRequest $downloadUrl
    [System.IO.File]::WriteAllBytes($localFilename, $webResponse.Content)       
}

$html = Invoke-WebRequest "http://www.visualsvn.com/visualsvn/download/tortoisesvn/"
$downloadUrl = $html.Links | where href -like "*tortoisesvn*-x64-*.msi" | select href

$downloadUrl = 'http://www.visualsvn.com' + $downloadUrl.href

"Downloading $downloadUrl ..."

DownloadFile($downloadUrl)


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images