ConfigMgr 2007 Desired Configuration Management CIs using PowerShell

We had a request in the forums today for guidance on how one could use PowerShell in a Desired Configuration Manager configuration item in ConfigMgr 2007. I wanted to take 10 minutes and just post a bit of guidance in how you’d go about scripting CIs in PowerShell. You always want to be sure that a script is actually necessary of course. Many CIs can be handled with registry or WMI checks.

A Simple Example

With the most basic DCM script example, you can check for a true / false condition. To work with DCM, you want to write your script to return a true or false response ($true or $false, 1 or 0…these are equivalent terms in script terms). Here is a very simple yet realistic example in which we check to verify that local guest user is disabled on a Windows computer. It echoes true if the guest user is disabled (meaning system is compliant) and false if it’s not (meaning system is non-compliant).  However, the IF-THEN logic here can be utilized in more complex scenarios.

#### Begin Sample Script ####

$AccountStatus = Get-WmiObject Win32_UserAccount -computername “localhost” -filter “LocalAccount=True AND`
Name=’Guest'” | Select-Object Disabled

if ($AccountStatus = $true){

return 1
return 0

#### End Sample Script ####

How to Implement a Script CI

How to implement a script in a CI is already nicely explained in this 4 minute video from Jason Lewis at Microsoft (click below to be redirected to his series on TechNet Edge). In fact, Jason’s example shows how to configure a VBScript that checks to verify local user is disabled! (indidentally, VBScript, JSCript and PowerShell are the supported scripting languages)



More Guidance for DCM

You can also repurpose OpsMgr 2007 scripts used in two-state monitors as DCM scripts as explained HERE. The conversion process is simple and can be a time-saver. You can also read Simon’s 4-part DCM authoring blog series HERE.

Configuration Packs from Microsoft can be found on the PinPoint catalog at

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.