Skip to content

Instantly share code, notes, and snippets.

View DarkAllien's full-sized avatar

Octavian Cordos DarkAllien

View GitHub Profile
CollID CollType FilterName UpdatesLast UpdatesOverall SCEP
XXX00019 Workstations Workstations True True True
XXX0001A Servers Servers True True True
XXX00018 Servers SubCollection1 True True True
XXX00015 Servers SubCollection2 True False True
[[inputs.exec]]
commands = ["powershell C:/Telegraf_Scripts/updates.ps1"]
interval = "40s"
timeout = "25s"
data_format = "influx"
BEGIN
--replace all CM_XXX with your SCCM DB name
DECLARE @UserSIDs VARCHAR(16);
SELECT @UserSIDs = 'disabled';
-- Master/Top servers collection ID with updates deployed as required
DECLARE @CollID VARCHAR(8)= 'XXX00111';
DELETE FROM [grafana].[dbo].[Servers]
WHERE [filter] = 'Servers.Patching.Required.Overall';
DECLARE @AuthListLocalID AS INT;
#Parameters
$SQL_Server = '<your SCCM SQL server>'
$Database ='<your SCCM Database>'
$Server_Collection = '<your server collection ID>'
$Workstation_Collection = '<your workstation collection ID>'
#Clients queries
$sqlCmd = "
DECLARE @date DATETIME;
SELECT @date = DATEADD([hh], -12, GETDATE());
###############################################################################
# INPUTS #
###############################################################################
# Windows Performance Counters plugin.
# These are the recommended method of monitoring system metrics on windows,
# as the regular system plugins (inputs.cpu, inputs.mem, etc.) rely on WMI,
# which utilize more system resources.
#
# See more configuration examples at:
# https://github.com/influxdata/telegraf/tree/master/plugins/inputs/win_perf_counters
[[inputs.exec]]
commands = ["powershell C:/Telegraf_Scripts/Clients.ps1"]
interval = "20s"
timeout = "30s"
data_format = "influx"
SELECT [aa].[AssignmentID]
FROM [v_ApplicationAssignment] [aa]
WHERE [ApplicationName] = @AppInfo
AND [aa].[CollectionID] = @CollID;
SELECT DISTINCT
[aa].[ApplicationName]
FROM [v_ApplicationAssignment] [aa]
ORDER BY 1;
SELECT DISTINCT
[aa].[CollectionID],
[aa].[CollectionName]
FROM [v_ApplicationAssignment] [aa]
WHERE [aa].[ApplicationName] = @AppInfo
ORDER BY 2;
DECLARE @PolicyModelID INT;
SELECT @PolicyModelID = [PolicyModelID]
FROM [fn_rbac_DeploymentSummary]([dbo].[fn_LShortNameToLCID](@locale), @UserSIDs)
WHERE [AssignmentID] = @AssignmentID;
SELECT *
INTO [Deployment0]
FROM
(
SELECT [AppState].[MachineName],