Just a quick post on an SCCM powershell cmdlet that is not referenced well enough on the web for running and testing your SCCM WQL queries:
It allows you, without connecting to WMI / without specifying your server name or site code or the namespace that you have to google every time.
This can be used to get some data on your database but also to easily test your query for collections.
$WQL = @”
SELECT app.* FROM SMS_ApplicationLatest AS app
INNER JOIN SMS_CIContentPackage AS con ON app.CI_ID=con.CI_ID
INNER JOIN SMS_DistributionPoint AS srv ON con.PackageID=srv.PackageID
WHERE app.IsHidden = 0
The easy way: Invoke-CMWmiQuery -Query $WQL
The old way: Get-WmiObject -Query $WQL -ComputerName “SCCMSERVER” -Namespace “root\sms\site_PRI”