PoshCode Archive  Artifact [1ffe1fd9a3]

Artifact 1ffe1fd9a36978e1c5fc82c9bc1f83ef4a661f3cbfcf83924c702e2f35c6693f:

  • File get-kbinfo.ps1 — part of check-in [80265a46e8] at 2018-06-10 13:02:25 on branch trunk — Identifying knowledge base article by its id number taken from string or filename. (user: Kris Cieslak size: 1490)

# 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: 1881
# x-archived: 2010-06-10T04:29:40
#
#
# -==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#        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