Last active
August 29, 2015 14:24
-
-
Save aaronpmiller/4e3ea1ae8dc398e27375 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-CodeplexDownload { | |
PARAM( | |
[string]$projectName | |
) | |
try { | |
$releaseURI = "http://$projectName.codeplex.com/releases" | |
$response = Invoke-WebRequest -Uri $releaseURI | |
#$version = $response.Links.FindById('fileDownload0').outerText | |
$version = ($response.AllElements | ? {$_.Class -eq 'page_title wordwrap'} | Select -First 1).outerText.Split(' ') | ? {$_ -like "*[0-9]"} | |
$changeSetId = $response.Links.FindById('ChangesetIDAnchor').outerText | |
#$downloadURI = "http://download-codeplex.sec.s-msft.com/Download/SourceControlFileDownload.ashx?ProjectName=$projectName&changeSetId=$changeSetId" | |
$downloadURI = $response.Links.FindById('fileDownload0').href | |
$tmpfilename=[System.IO.Path]::GetTempFileName() | |
Remove-Item -Path $tmpfilename | |
$parts = $tmpfilename.Replace('.tmp',".zip").Split('\') | |
$parts[-1] = @($projectName,$version,$changeSetId,$parts[-1]) -join ' ' -replace ' ','_' | |
$tempfilename = $parts -join '\' | |
[io.file]::WriteAllBytes($tempfilename,(Invoke-WebRequest -URI $downloadURI).content) | |
$item = '' | Select ProjectName,Version,ChangeSetId,tempfilename | |
$item.ProjectName = $projectName | |
$item.Version = $version | |
$item.ChangeSetId = $changeSetId | |
$item.tempfilename = $tempfilename | |
$item | |
} catch { | |
Write-Error 'There was an error, please make sure you provided an accurate CodePlex project name.' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment