Using a PowerShell Configuration Baseline to Deploy CMTrace

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

First published on TECHNET on Apr 01, 2016

Authored by Danny Guillory


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.

So getting CMTrace out in the infrastructure is fairly straight forward, so let's get started.

Objective:

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


To get started here 1 st 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 1 st objective. We need CMTrace in the windows\system32 folder to be able to execute CMTrace from the RUN command.

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)



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



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 if 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.











Configuration Baseline Configuration:



NOTES:

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



@SCCMAvenger

Deploy CMTrace.zip

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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