top of page
  • Writer's pictureshishir kushawaha

Compress log file using PowerShell to view only errors

Updated: Jan 29

Often SCCM and other Windows log files are very lengthy and it may take lot of time to read the error. For e.g. setupact.log or smsts.log. What if you can compress it and that only contains error. This post will give you the overview and script to do this.

This script will read the log file and create a new log file with lines having only error , failed statement. This will make easy to read log file as this will not have normal execution statement. Script will only extract the statement which will have exception type=3 or failed statement.

Processing of script :

  • Script will take the original log file as a input.

  • Will create another output log file.

  • It will read log file line by line.

  • if any line have any exception value as 3 or contains word like 'fail', 'failure', 'error' etc., it will add that specific line to output log file.

$LOG_CONTENT | ForEach-Object{if(($_ -match 'type="3"') -or ($_ -match "failed") -or ($_ -match "fail") -or ($_ -match "error")){<statement>}
  • Using CMtrace the output log file can be viewed and errors can be traced easily without reading entire log file.

You can download script from GitHub repository. #MECM #SCCM #logfile #Compressedlogfile

398 views0 comments

Recent Posts

See All
bottom of page