Devices with a specific installed KB

Devices with a specific installed KB

Written by Ines

Last published at: October 6th, 2021

PS Script

Script Events:

  1. Discovers all devices
  2. Discovers their inventories and extrapolates all installed updates, and then filters the specific one
  3. Returns all results


Script example:

Script:

#parameters

$serverURI = 'server'

$KB = 'KB4574727'

#script

$creds = Get-Credential

Connect-TSTMGMTServer -Uri $serverURI -Credentials $creds

$Devices = Get-TSTMGMTDevices

$Results = foreach ($D in $Devices) {


    $D | Get-TSTMGMTDeviceInventory | Select -ExpandProperty InstalledWindowsUpdates | where {$_.KB -eq $KB} | select -Last 1 @{n='Device';e={$D.DeviceName}},

    @{n='Product';e={$D.ProductType}}, KB, Name, DateApplied | sort DateApplied -Descending 

}

$Results | ft

TSQL variation

Script Example:


Script:

select distinct DE.DeviceName, WU.KB, WU.Name, Wu.DateApplied, 

'ProductType' = CASE

WHEN DE.ProductType = 0 THEN 'TK'

WHEN DE.ProductType = 4 THEN 'SRW'

END

from WindowsUpdates WU

inner join Devices DE on WU.DeviceId = DE.DeviceId

where WU.KB = 'KB4574727'