Skip to content

Instantly share code, notes, and snippets.

@tomasr
Created October 24, 2017 16:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomasr/d4f2ed79caa857ab0e58a34e28e5541a to your computer and use it in GitHub Desktop.
Save tomasr/d4f2ed79caa857ab0e58a34e28e5541a to your computer and use it in GitHub Desktop.
Sample script to json-scrape support site for KB titles
$source = Import-CSV ".\hotfixesAll.csv"
$knownHotfixes = @{}
function Get-HotfixUrl($hotfixId) {
$id = $hotfixId
if ($hotfixId.StartsWith('KB')) {
$id = $hotfixId.Substring(2)
}
return "https://support.microsoft.com/app/content/api/content/help/en-us/$id"
}
function Get-HotfixTitleFromUrl($url) {
$html = Invoke-WebRequest -Uri $url -Method GET
$json = ConvertFrom-Json $html
return $json.details.heading
}
function Get-HotfixTitle($hotfixId) {
if ($knownHotfixes.ContainsKey($hotfixId) ) {
return $knownHotfixes[$hotfixId]
}
$url = Get-HotfixUrl $hotfixId
$title = Get-HotfixTitleFromUrl $url
if (![String]::IsNullOrEmpty($title)) {
$knownHotfixes[$hotfixId] = $title
}
return $title
}
foreach ($hf in $source) {
$title = Get-HotfixTitle $hf.HotfixID
$hf | Add-Member -MemberType NoteProperty -Name Title -Value $title
}
$source | Export-CSV .\hotfixesWithTitle.csv -NoTypeInformation
@wagde-orca
Copy link

it seems that the link return "https://support.microsoft.com/app/content/api/content/help/en-us/$id" is dead :-(
Any idea what is the new link?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment