Skip to content

Instantly share code, notes, and snippets.

@MukeshLohar
MukeshLohar / SU Compliance by Device.sql
Created August 1, 2022 04:15 — forked from Ioan-Popovici/SU Compliance by Device.sql
Gets the software update compliance in SCCM by Device and All Updates.
/*
.SYNOPSIS
Gets the software update compliance for a device in SCCM.
.DESCRIPTION
Gets the software update compliance in SCCM by Device and All Updates.
.NOTES
Requires SQL 2012 R2.
Part of a report should not be run separately.
*/
/* Testing variables !! Need to be commented for Production !! */
DECLARE @UserSIDs AS NVARCHAR(10) = 'Disabled';
DECLARE @CollectionID AS NVARCHAR(10) = 'SMS00001'
DECLARE @OnInternet AS NVARCHAR(3) = '0' --You could make this into a multiselection in the report
SELECT
Device = (
IIF(
SystemNames.Resource_Names0 IS NOT NULL, UPPER(SystemNames.Resource_Names0)
, IIF(Systems.Full_Domain_Name0 IS NOT NULL, ClientBaseline.Name + '.' + Systems.Full_Domain_Name0, ClientBaseline.Name)