Write-Log Severity not working

Hello all, for some reason, the -severity parameter on the Write-Log function doesn’t seem to be working, what could I be doing wrong?

I’m setting a variable if a machine equals a certain condition, then if that variable equals 1, I want to write to the log and highlight in yellow so it can stand out. Below is a summarized version of my code:

If ($variable -eq 1) {Write-Log -Message “IT Device” -Severity 2 -LogType CMTrace

I have tried without the LogType and I have tried storing the severity to a variable and calling that up for the parameter.

You need to read the log with cmtrace.exe which is part of the Configuration Manager toolkit and also now part of the Configuration Manager client installation.

Reading the log in CMTrace does nothing. There still is no highlighting of warnings or errors created by Write-Log and -Severity 2 or 3.

This isn’t technically a bug in the toolkit but I’m gonna post a PR anyway. Basically, there are columns that you display. If one is empty, highlighting doesn’t work. If you do Write-Log without -Source, there’s no content for one column and CMTrace doesn’t highlight anything.

Thanks luki412 for the info. For example, my script is looking for a file that defines what type of device the script is installing like an IT device. If the file exists I would like to write to the log its an IT device and highlight that line yellow (severity 2), I’m a little confused about the -Source parameter.

In this example, what would I put in the -Source parameter?

You usually want the name of a function in there that’s triggering the Write-Log. Any text will work though.

That did the trick, thanks! I just put PSAppDeployToolkit in the source parameter. This is great and will be a huge help when our Tier 2 team troubleshoots. Thanks again!