Hi LS experts,
I have a customer who would like to pay for Extended support for their Windows 7 machines.
Microsoft have released this information as of end of November 2019 and it requires a set of prerequisite KB patches to be installed first.
(More at https://techcommunity.microsoft.com/t5/Windows-IT-Pro-Blog/How-to-get-Extended-Security-Updates-for-eligible-Windows/ba-p/917807)
So I thought i'd use the LS install that they have to scan for Win 7 machines and then detect the KB numbers.
To do this I have 'borrowed' the code published for the Monthly Patch Tuesday and adjusted for my use.
The problem is that when I tested it against a machine with all the patches installed, it doesn't show as complete.
Win 7 needs:
- Service Pack 1 (KB976932) but haven't looked for that specifically.
- The March servicing stack update (SSU) - KB4490626
- The SHA2 code sign patch - KB4474419
- The September SSU - KB4516655
- Any Monthly Roll Up from October onwards - KB4519976, KB4519972, KB4525235, KB4525251, KB4530734
In the code below I have use the IN statement to list the Monthly Roll Ups, then added an AND for each of the remaining three KB numbers.
I can see it works if I just check for each KB number one at a time (as the one machine with them all will show as green each time). Likewise adding them as OR statements seems to work and shows those machines that have at least one of the patches installed... But I need all of the three plus one of the Roll Ups.
I'm guessing this is a fault because when using an OR statement you just get a single result, with AND you will get multiple possible matches - unfortunately my SQL isn't up to knowing how to fix that!
Please can you take a look at the below and advise.
Kudos to those that can fix it.
I suspect others will benefit from this code too - now that Windows 7 is about to go EOL!
My code:
Select Distinct Top 1000000 Coalesce(tsysOS.Image,
tsysAssetTypes.AssetTypeIcon10) As icon,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
Case tblAssets.AssetID
When SubQuery1.AssetID Then 'Up to date'
Else 'Out of date'
End As [Patch status],
Case
When tblComputersystem.Domainrole > 1 Then 'Server'
Else 'Workstation'
End As [Workstation/Server],
tblAssets.Username,
tblAssets.IPAddress,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname As OS,
tblAssets.SP,
tblAssets.Lasttried,
Case
When tblAssets.AssetID = SubQuery1.AssetID Then ''
Else 'Still needs ESU Patches'
End As [Install ESU Patches],
Convert(nvarchar,DateDiff(day, QuickFixLastScanned.QuickFixLastScanned,
GetDate())) + ' days ago' As WindowsUpdateInfoLastScanned,
Case tblAssets.AssetID
When SubQuery1.AssetID Then '#d4f4be'
Else '#ffadad'
End As backgroundcolor
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblOperatingsystem On tblOperatingsystem.AssetID =
tblAssets.AssetID
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Left Join tsysOS On tsysOS.OScode = tblAssets.OScode
Left Join (Select Top 1000000 tblQuickFixEngineering.AssetID
From tblQuickFixEngineering
Inner Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID
= tblQuickFixEngineering.QFEID
Where tblQuickFixEngineeringUni.HotFixID In ('KB4519976', 'KB4519972',
'KB4525235', 'KB4525251', 'KB4530734') And
tblQuickFixEngineeringUni.HotFixID = 'KB4490628' And
tblQuickFixEngineeringUni.HotFixID = 'KB4474419' And
tblQuickFixEngineeringUni.HotFixID = 'KB4516655') As SubQuery1
On tblAssets.AssetID = SubQuery1.AssetID
Left Join tsysIPLocations On tblAssets.IPNumeric >= tsysIPLocations.StartIP
And tblAssets.IPNumeric <= tsysIPLocations.EndIP
Left Join (Select Distinct Top 1000000 TsysLastscan.AssetID As ID,
TsysLastscan.Lasttime As QuickFixLastScanned
From TsysWaittime
Inner Join TsysLastscan On TsysWaittime.CFGCode = TsysLastscan.CFGcode
Where TsysWaittime.CFGname = 'QUICKFIX') As QuickFixLastScanned On
tblAssets.AssetID = QuickFixLastScanned.ID
Left Join (Select Distinct Top 1000000 tblErrors.AssetID As ID,
Max(tblErrors.Teller) As ErrorID
From tblErrors
Group By tblErrors.AssetID) As ScanningError On tblAssets.AssetID =
ScanningError.ID
Left Join tblErrors On ScanningError.ErrorID = tblErrors.Teller
Left Join tsysasseterrortypes On tsysasseterrortypes.Errortype =
tblErrors.ErrorType
Where tsysOS.OSname Like 'Win 7%' And tblAssetCustom.State = 1 And
tsysAssetTypes.AssetTypename Like 'Windows%'
Order By tblAssets.AssetName
Many Thanks
Andy