Skip to content

Instantly share code, notes, and snippets.

@rchaganti
Created May 28, 2014 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rchaganti/f296becb397f29b27131 to your computer and use it in GitHub Desktop.
Save rchaganti/f296becb397f29b27131 to your computer and use it in GitHub Desktop.
Get Python download MSI object
Function Test-Url {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String] $Url,
[Parameter()]
[Switch] $ReturnUri
)
Process {
if ([system.uri]::IsWellFormedUriString($Url,[System.UriKind]::Absolute)) {
$true
} else {
$false
}
}
}
$Msi = @()
$doc = Invoke-WebRequest -Uri 'https://www.python.org/downloads'
foreach ($href in ($doc.links.href -ne '')) {
if ((Test-Url -Url $href) -and $href.EndsWith('.msi')) {
$uri = [System.uri]$href
$Msi += New-Object -TypeName PSObject -Property @{
"Url" = $href
"Version" = $Uri.Segments[-2].Replace('/','')
}
}
}
$Msi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment