Created
September 3, 2015 23:36
-
-
Save michaellwest/3f3730646ac82aa076c2 to your computer and use it in GitHub Desktop.
The script pulls the latest list of Sitecore Marketplace modules, including the release and revision dates.
This file contains 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
$VerbosePreference = "Continue" | |
$relpattern = "(<label>Release date:</label>\s*<span.*>(?<release>[0-9/:AMP\s]*)</span>)" | |
$revpattern = "(<label>Revision date:</label>\s*<span.*>(?<revision>[0-9/:AMP\s]*)</span>)" | |
function Get-PageContent { | |
param( | |
[string]$Link | |
) | |
[System.Net.HttpWebRequest]$r = [System.Net.WebRequest]::Create("https://marketplace.sitecore.net" + $Link) | |
[System.Net.HttpWebResponse]$resp = $r.GetResponse() | |
$reqstream = $resp.GetResponseStream() | |
$sr = New-Object System.IO.StreamReader $reqstream | |
$sr.ReadToEnd() | |
} | |
Write-Verbose "Requesting the list of available modules." | |
if(!$searchResponse) { | |
$searchResponse = Invoke-RestMethod -Uri "https://marketplace.sitecore.net/Services/Modules.svc/Search" -Method Post -ContentType "application/json;charset=UTF-8" -Body '{"query":"", "offset":"0", "count":"1000", "category":"", "requirement":"", "familyIds":[], "support":"" }' | |
} | |
$modules = $searchResponse.more.items | Where-Object { $_.ModuleName } | Select-Object -Property ModuleName, Description, Link, Like | Sort-Object -Property Like -Descending | |
foreach($module in $modules) { | |
Write-Verbose "Downloading the module page $($module.modulename)" | |
$page = Get-PageContent -Link $module.link | |
if($page) { | |
if($page -match $relpattern) { | |
$release = [datetime]$Matches["release"] | |
$module | Add-Member -Name "release" -Value $release -MemberType NoteProperty | |
} | |
if($page -match $revpattern) { | |
$revision = [datetime]$Matches["revision"] | |
$module | Add-Member -Name "revision" -Value $revision -MemberType NoteProperty | |
} | |
Write-Verbose "$($module.modulename) : rev - $($module.revision) : rel - $($module.release)" | |
} else { | |
Write-Verbose "No page content found" | |
} | |
} | |
$modules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment