Using Powershell Internet Explorer Object automation to save work!

Published August 23, 2013 by FoxDeploy

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ā€™

Microsoft MVP

Five time Microsoft MVP, and now I work for the mothership


Need Help?

Get help much faster on our new dedicated Subreddit!

depicts a crowd of people in a night club with colored lights and says 'join the foxdeploy subrreddit today'


Blog Series
series_sml_IntroToDsc
series_sml_PowerShellGUI series_sml_IntroToRaspberryPi Programming series_sml_IntroToWindows Remote Management Series The Logo for System Center Configuration Manager is displayed here Depicts a road sign saying 'Learning PowerShell Autocomplete'




Blog Stats