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.
- 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.
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"
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 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.
Configuration Baseline Configuration:
Change values and locations as needed within the script. This script and Configuration Baselines are meant for testing use only.