简体   繁体   中英

SCCM PowerShell Get Configuration Baseline computers

I am working with Configuration Baselines. I would like to start from "Get-CMBaseline -Name MyBaselineName" and work my way to the name of the machines. I am try to figure out how to get the machines names that are "Compliant", "Error", and "Non-Compliant". I see the names of the machines in "Deployment Status" but I need them via PowerShell.

There are many things that are possible via the built in cmdlets but some just are not (yet?). However it is almost always possible to get the same behavior the console has with wmi (because the console uses wmi itself)

To find out how it is good to know that there is a log file "SMSProv.log" that tells you what the console does for every dialog you open. It is located on the site server wherever you installed the ConfigMgr in a sub-folder Logs (so default would be %Program Files%\\Microsoft Configuration Manager\\Logs).

So if you use that when checking the deployment status of a baseline you will notice that it basically translates to 3 commands (All in the namespace

Root\SMS\site_<SiteCode>

on your siteserver):

SELECT * FROM SMS_DCMDeploymentCompliantAssetDetails WHERE AssignmentID=<AssignmentID>

SELECT * FROM SMS_DCMDeploymentNonCompliantAssetDetails WHERE AssignmentID=<AssignmentID>

SELECT * FROM SMS_DCMDeploymentErrorAssetDetails WHERE AssignmentID=<AssignmentID>

where AssignemtID is the ID you would get eg from

(Get-CMBaselineDeployment -Name "<Your Baslines Name>").AssignmentID

A little exception would be that the console filters the error further by error type but to me it seems like this is maybe not even what you want and you could easily do it in Powershell later if you need to.

The SQL command is also available in most cases in the SMSProv.log, and in some cases it leads to a faster execution. However in this one probably not really and it is a lot more complex most of the time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM