ConfigMgr Client Boundary and Boundary Group memberships SQL Query

ConfigMgr current branch SQL query to return the boundaries and boundary groups systems are part of.

https://github.com/NecroMonkey/vault/blob/master/SQL/client_boundary_membership_update.sql


SELECT DISTINCT
sysr.Netbios_Name0,
ipr.Name as [Boundary],
ipr.BoundaryType as [Type],
bg.Name AS [Boundary Group]
FROM     v_R_System AS sysr INNER JOIN
                  System_IP_Address_ARR AS ip ON ip.ItemKey = sysr.ResourceID AND ip.NumericIPAddressValue <> 0 INNER JOIN
                  v_RA_System_IPSubnets AS sub ON sub.ResourceID = sysr.ResourceID LEFT OUTER JOIN
                  v_RA_System_IPv6Prefixes AS v6 ON v6.ResourceID = sysr.ResourceID INNER JOIN
                  BoundaryEx AS ipr ON ipr.BoundaryType = 3 AND ip.NumericIPAddressValue BETWEEN ipr.NumericValueLow AND ipr.NumericValueHigh OR
                  ipr.BoundaryType = 1 AND ipr.Value = sysr.AD_Site_Name0 OR
                  ipr.BoundaryType = 0 AND ipr.Value = sub.IP_Subnets0 OR
                  ipr.BoundaryType = 2 AND ipr.Value = v6.IPv6_Prefixes0 INNER JOIN
                  vSMS_BoundaryGroupMembers as bgm ON ipr.BoundaryID = bgm.BoundaryID INNER JOIN
                  vSMS_BoundaryGroup as bg ON bgm.GroupID = bg.GroupID
GROUP BY sysr.Netbios_Name0, ipr.Name, ipr.BoundaryType, bg.Name
ORDER BY sysr.Netbios_Name0, ipr.Name, bg.Name

ConfigMgr Client Content Breakdown SQL Query

This SQL query for ConfigMgr current branch gives a breakdown of client content.  It is also on my GitHub at https://github.com/NecroMonkey/vault/blob/master/SQL/ConfigMgr_content_source_breakdown.sql

 


drop table if exists ##temp1
drop table if exists ##temp2

SELECT distinct sysr.Name0,
sysr.ResourceID, ipr.Name as [Boundary],
ipr.Value
into ##temp1
FROM v_R_System sysr
JOIN System_IP_Address_ARR ip ON ip.ItemKey = sysr.ResourceID AND ip.NumericIPAddressValue <> 0    
JOIN v_RA_System_IPSubnets sub ON sub.ResourceID = sysr.ResourceID      
LEFT JOIN v_RA_System_IPv6Prefixes v6 ON v6.ResourceID = sysr.ResourceID
JOIN BoundaryEx AS ipr ON
-- Check BoundaryType 3 (IPRANGE)
(ipr.BoundaryType = 3 AND ip.NumericIPAddressValue BETWEEN ipr.NumericValueLow AND ipr.NumericValueHigh)
-- Check BoundaryType 1 (ADSITE)
OR (ipr.BoundaryType = 1 AND ipr.Value = sysr.AD_Site_Name0)
-- Check BoundaryType 0 (IPSUBNET)
OR (ipr.BoundaryType = 0 AND ipr.Value = sub.IP_Subnets0)
-- Check BoundaryType 2 (IPv6)
OR (ipr.BoundaryType = 2 AND ipr.Value = v6.IPv6_Prefixes0)
order by sysr.ResourceID

select rsys.Name0, rsys.ResourceID,
"Content Source Type" = CASE cdhs.DistributionPointType
WHEN 1 THEN 'Cloud DP (Distribution Point)'
WHEN 2 THEN 'Management Point'
WHEN 3 THEN 'Peer Cache'
WHEN 4 THEN 'DP (Distribution Point)'
WHEN 5 THEN 'BranchCache'
WHEN 6 THEN 'Delivery Optimization Peer'
WHEN 7 THEN 'Delivery Optimization Cache Server'
WHEN 8 THEN 'Microsoft Update'
END,
packages.Name as [Content],
cdhs.ContentID,
CAST(SUM(cast(cdhs.BytesDownloaded as float)) / 1073741824 AS DECIMAL(10,2)) as [GB]
into ##temp2
from
v_R_System as rsys
join ClientDownloadHistory as cdh on rsys.ResourceID = cdh.ClientId
join ClientDownloadHistorySources as cdhs on cdh.id = cdhs.DownloadHistoryID
join ClientDownloadHistoryBoundaryGroups as cdhbg on cdh.id = cdhbg.DownloadHistoryID JOIN
                         v_FullCollectionMembership AS a ON rsys.ResourceID = a.ResourceID JOIN
                         v_Collection AS b ON b.CollectionID = a.CollectionID LEFT JOIN CI_Contentpackages CI on CI.Content_UniqueID = cdhs.ContentID
JOIN smspackages packages on packages.PkgID = ISNULL(CI.PkgID,cdhs.ContentId)
where (b.CollectionID = 'SMSDM003')
group by rsys.Name0, rsys.ResourceID, cdhs.DistributionPointType, packages.Name, cdhs.ContentID
order by rsys.Name0, rsys.ResourceID, cdhs.DistributionPointType, packages.Name, cdhs.ContentID

select
t1.Name0, t1.Boundary, t1.Value, t2.[Content Source Type], t2.Content, t2.GB
from ##temp1 as t1 join
##temp2 as t2 on t1.ResourceID = t2.ResourceID

drop table if exists ##temp1
drop table if exists ##temp2

ConfigMgr Run Script – Kickoff Compliance Baseline Check

I came across a code snippet by Mick Pletcher () that you can add to the end of a compliance item script to kick off the evaluation of a baseline. I took that and added a parameter to it so you can use it as a ConfigMgr Run Script. It look like a lot of code but 90% is just documentation.

Continue reading “ConfigMgr Run Script – Kickoff Compliance Baseline Check”

ConfigMgr PowerShell Script – Create Collections off Compliance Settings Configuration Items

The script uses Get-CMConfigurationItem cmdlet to get a list of LocalizedDisplayNames of Compliance Setting CIs and then runs a Foreach to create three collections based using the LocalizedDisplayName. Parameters specify the CM Site Code, Limiting Collection collection ID, and the CI Name. It does a check to see if a collection exists beofre creating which is also a self repair feature as a deleted collection will be recreated.

Continue reading “ConfigMgr PowerShell Script – Create Collections off Compliance Settings Configuration Items”

ConfigMgr Run Script – Set Service State

As you can tell, many of my script posts occur after something was needed at work and I ended scripting it. This time we needed to alter the startup of a service on a group of systems. I wrote this PowerShell script to set the startup type and status of a specified service. It does require three parameters: service name, startup type desired, and desired status.

Continue reading “ConfigMgr Run Script – Set Service State”

ConfigMgr Log Collector Run Script

In most environment I have worked in, I have not had access or easy access to some systems I was expected to troubleshoot ConfigMgr issues on especially servers.  I would normally have to ask for someone to send me logs and half the time needed to explain where to find that logs.  I wrote a quick ConfigMgr Run Script that I can target against a system or collection and no longer have to ask for logs because the script will get them for me.

Continue reading “ConfigMgr Log Collector Run Script”

ConfigMgr Content Source Breakdown Report

We recently start implementing BranchCache and PeerCache with ConfigMgr. I wanted to be able to report back to management where clients were getting content, how much was being downloaded, what the top content grabbed by source type, number of peer source by domain, boundaries missing PeerCache super peers, and peer content source counts by boundary. It is a lot of data and takes some time to run, but I felt the need to share my report with others.

RDL file is in my GitHub repository – https://github.com/NecroMonkey/vault/blob/master/SSRS-Reports/ContentSourceBreakdown/Content%20Source%20Breakdown.rdl