Using Powershell Internet Explorer Object automation to save work!
Hi all,
At one client, I had to use the Microsoft Baseline Security Analyzer to obtain a list of locally installed patches on all workstations. Ā This application runs a check for installed patches on target workstations, and returns the output of a .CSV file (Iām leaving out some steps, but this is close enough.) Ā However, this list leaves a lot to be desired, namely what the patches or KBs were meant to address, among other issues. Ā As the clients wanted to review over and approve each update before proceeding with the project, I had to do something about this.
I could have manually googled each KB to see what the article said about them, but that would take way too much time, as there were hundreds of individual updates installed around the environment.
To solve this problem I used Powershell to create this function which reads the KB numbers from the CSV file, automates an invisible Internet Explorer object, and then reads the page title from each article (which, fortunately enough, contained a nice summary of the purpose of each KB!) to fill in the missing information.
Iāve since reused this at other clients and saved countless hours of manual work, I hope it will help you!
$ie = new-object -com āInternetExplorer.Applicationā
$i=$null
$entries = (Import-Csv āF:\Consulting Tools\MBSA\_desktop_installed_patches.csvā).Count
$values = Import-Csv āF:\Consulting Tools\MBSA\_desktop_installed_patches.csvā | % {
$i++;
Write-host ā$i out of $entriesā
if ($_.Description.Length -le 2){
$kbNo = $_.ServicePackInEffect.Replace(āKBā,āā)
$ie.navigate(āhttp://support.microsoft.com/kb/$kbNoā)
while($ie.busy) {
Write-host āLoadingā¦ā;
start-sleep -Milliseconds 25
} #$ie.LocationName
$_.Description = $ie.LocationName
$kbNo ;
$_.Description }
} | Export-Csv āC:\temp\_desktop_installed_patches_converted.csvā