Using a PowerShell Configuration Baseline to Deploy CMTrace

As a Premier Field Engineer, I spend a lot of time with customers coast to coast. One common thing I have seen is customers constantly looking for their favorite log viewer (at least mines 🙂 .

Configuration Baselines to the rescue.

Anyone that knows me knows I am a huge fan of configuration baselines since they can enable so much outside the box thinking, valuable workflows, and automation workflows that can be presented, OMG it’s insane, the fun stuff you can do with Configuration Baselines. Another story for another day Smile

So getting CMTrace out in the infrastructure is fairly straightforward, so let’s get started.

Objective:

  • From an RUN Command, type in CMTRACE and have CMTrace pop up.

To get started here 1st we need to figure out the commands needed to test for the existence of CMTrace. Now before we do that, we need to consider the 1st objective. We need CMTrace in the windows\system32 folder to be able to execute CMTrace from the RUN command line.

Phase One: (Testing for the file)

To test for the existence of CMTrace we can use the Test-Path PowerShell command. Why PowerShell you may ask because POWERSHELL IS KING, and I can further tune this as much as I would like for any scenario.

#look for cmtrace.exe
$cmtrace = Test-Path “c:\windows\System32\cmtrace.exe”
$cmtrace

As you can see I store the results of the Test-Path commandlet as a variable, so I can use that variable to evaluate the True or False from the variable.

The below picture is a negative evaluation. (Meaning CMTrace IS NOT in the tested location)

clip_image002[1]

After I put CMTrace in the tested path you get the picture below showing a good evaluation. (Meaning CMTrace IS in the tested location)

clip_image004[1]

Phase Two: (Remediating the file)

Now that we know how to test for the existence of the file and we also have the extra value of evaluating the file existence on True or False, we can get down to remediation if the value equals false.

#copy cmtrace to c:\temp

Copy-Item -Path “\\scapss\SMS_SCA\tools\cmtrace.exe” -Destination “C:\Windows\System32\cmtrace.exe” -Verbose

Phase Three: (Putting it Together)

Now that we know how to detect for the file and remediate of the file IS NOT there. Off to create our Configuration Item with Remediation and Configuration Baseline to deploy.

Below you will see screenshots of how the Configuration Item is Configured.

clip_image006[1]

clip_image008[1]

clip_image010[1]

clip_image012[1]

Configuration Baseline Configuration:

clip_image014[1]

NOTES:

Change values and locations as needed within the script. This script and Configuration Baselines are meant for testing use only.

 

@SCCMAvenger

Advertisements
This entry was posted in Configuration Baselines, configuration mamanger, configuration manager 2012 and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s