Bite my bytes

What I learn by day I blog at night - A blog from Microsoft Consultant working from Ljubljana, Slovenia

  Home :: Contact :: Syndication  
  999 Posts :: 7691 Comments :: 235 Trackbacks

Search

Most popular posts
in last 180 days

Categories

My Projects

Archives

Stuff


Copyright © by David Vidmar
 
Contact me!
 
LinkedIn Profile
 
 
 

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)

Posted on Sunday, September 02, 2012 11:55 PM | Filed under: Software System Developement Internet |

Feedback

# re: Updating TortoiseSVN with PowerShell 9/4/2012 9:39 AM Felix
finally we have an update after almost 1 year

Comments have been closed on this topic.