PoshCode Archive  Artifact Content

Artifact bb31dcaa6b855578bc22d8097a0cd2171996e139cf343c6c436d13bfb2fcdeae:

  • File get-kbinfo.ps1 — part of check-in [162787e7ff] at 2018-06-10 14:16:37 on branch trunk — Identifying knowledge base article by its id number taken from string or filename. (user: Kris Cieslak size: 1526)

# encoding: ascii
# api: powershell
# title: get-kbinfo
# description: Identifying knowledge base article by its id number taken from string or filename.
# version: 0.1
# type: script
# author: Kris Cieslak 
# license: CC0
# x-poshcode-id: 6476
# x-archived: 2016-08-21T07:19:09
# x-published: 2016-08-17T08:04:00
#
#
# -==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#        Author: Kris Cieslak (defaultset.blogspot.com)
#          Date: 2010-05-26
#   Description: Identifying knowledge base article by id number taken from 
#                string or filename.
#
#    Parameters: filename / knowledge base number
#               
#  Requirements: Internet connection
#
# Usage example:
#                ./get-kbinfo.ps1 KB926139 
#            or  
#                ./get-kbinfo.ps1 WindowsXP-KB926139-x86-ENU.exe
#            or 
#                ls Windows* | % { ./get-kbinfo.ps1 $_.Name }
#
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=--=-=-=-=-=-=-=-=-=-=
 PARAM ($filename = $(throw "Specifiy the file name"))

 $page = New-Object System.Net.WebClient;  
 $kb = [regex]::match($filename,'KB\d*|kb\d*').ToString();
 $p = $page.DownloadString('http://support.microsoft.com/kb/'+$kb)
 $p = [regex]::replace( [regex]::match($p,'<h1 class="title">.*</h1>').ToString(), '<h1 class="title">|</h1>', '' )
 write-host -Fore Yellow `n'[*] Filename: '$filename  
 write-host `n'    '$p `n'    ( http://support.microsoft.com/kb/'$kb' )'`n