This is my personal blog. The opinions and views I express are my own. The information I provide is on an as-is basis. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries or damages arising from its use.

Verify 3rd Party patches and HBSS updates with Powershell


I put this script together in order to verify 3rd party patches and McAfee HBSS updates are being applied across the network. I do not have access to our SCCM server; luckily powershell is there to do all the heavy lifting for me.

The script will read computer names from a .txt file and will gather the following information:
Computer Name
IP address
MAC address
Last Reboot Time
Logged in User
McAfee VirusScan Version
McAfee VirusScan Scan engine version
McAfee VirusScan DAT file version
McAfee HIPs version
Flash Player ActiveX version
Flash Player Plugin Version
Java Version and Adobe Acrobat Version

All the data is output to a CSV file. The script looks for certain registry key values in order to determine version for some of the software. If you’re running different versions of the software the registry path may be slightly different.

# On error the script will continue silently without 
$erroractionpreference = "SilentlyContinue"

# Share location of the txt file we're pulling computer names from
write-host -foregroundcolor cyan ""
write-host -foregroundcolor cyan "Testing Connection to each computer (this may take a while depending on the number of computers)"
$ComputerName = get-Content -Path "C:\scripts\computers.txt" | Where-Object {Test-Connection -ComputerName $_ -Quiet -Count 2}

# The results of the script are here
$exportLocation = "C:\scripts\softwareInventory.csv"

 foreach ($Computer in $ComputerName){
   $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer | ? {$_.IPEnabled}
   $OS = gwmi Win32_OperatingSystem -Computername $Computer
   $Hardware = get-wmiobject Win32_computerSystem -Computername $Computer
   $username = $Hardware.Username
   $lastBoot = $OS.ConvertToDateTime($OS.LastBootUpTime)

   # McAfee Product Info
   $virusScan = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$Computer).OpenSubKey('SOFTWARE\McAfee\DesktopProtection').GetValue('szProductVer')
   $scanEngine = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$Computer).OpenSubKey('SOFTWARE\McAfee\AVEngine').GetValue('EngineVersionMajor') 
   $Dat = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$Computer).OpenSubKey('SOFTWARE\McAfee\AVEngine').GetValue('AVDatVersion')
   $HIPVer = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$Computer).OpenSubKey('SOFTWARE\McAfee\HIP').GetValue('Version') 
   # End McAfee Product Info

   # Flash Player Product Info
   $FlashActiveX = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$Computer).OpenSubKey('SOFTWARE\Macromedia\FlashPlayerActiveX').GetValue('Version')
   $FlashPlugin = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$Computer).OpenSubKey('SOFTWARE\Macromedia\FlashPlayerPlugin').GetValue('Version')
   # End Flash Player Product Info

   # Java Product Info
   $JavaVer = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$Computer).OpenSubKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83216045FF}').GetValue('DisplayVersion')
   # End Java Product Info

   # Adobe Acrobat Product Info
   $acrobatVer = Get-Item "\\$Computer\c$\Program Files\Adobe\Acrobat 10.0\Acrobat\Acrobat.dll"
   # End Adobe Acrobat Product Info

   write-host -foregroundcolor yellow "Found $computer"

   foreach ($Network in $Networks) {
    $IPAddress  = $Network.IpAddress[0]
    $MACAddress  = $Network.MACAddress
    $systemBios = $Bios.serialnumber
    $OutputObj  = New-Object -Type PSObject
    $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
    $OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
    $OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress
    # The substring value will need to be changed to macth the length of your domain name + 1 
    # for the \. 
    $OutputObj | Add-Member -MemberType NoteProperty -Name UserName -Value $username.substring(7)
    $OutputObj | Add-Member -MemberType NoteProperty -Name Last_Reboot -Value $lastboot
    $OutputObj | Add-Member -MemberType NoteProperty -Name McAfee_VirusScan_Ver -Value $VirusScan
    $OutputObj | Add-Member -MemberType NoteProperty -Name McAfee_ScanEngine_Ver -Value $scanEngine
    $OutputObj | Add-Member -MemberType NoteProperty -Name McAfee_DatFile_Ver -Value $Dat
    $OutputObj | Add-Member -MemberType NoteProperty -Name McAfee_HIPS_Ver -Value $HIPVer
    $OutputObj | Add-Member -MemberType NoteProperty -Name Flash_ActiveX_Ver -Value $FlashActiveX
    $OutputObj | Add-Member -MemberType NoteProperty -Name Flash_Plugin_Ver -Value $FlashPlugin
    $OutputObj | Add-Member -MemberType NoteProperty -Name Java_Ver -Value $JavaVer
    $OutputObj | Add-Member -MemberType NoteProperty -Name Acrobat_Ver -Value $acrobatVer.VersionInfo.Productversion
    $OutputObj | Export-Csv $exportLocation -Append

 write-host -foregroundcolor cyan "Script is complete, the results are here: $exportLocation"


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.