-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Write messages to a log file in CMTrace.exe compatible format or Legacy text file format.
Write messages to a log file in CMTrace.exe compatible format or Legacy text file format and optionally display in the console.
Can also specify parameters via ${env:Write-Log}
variable. Store variables in as JSON. More in the wiki.
The message to write to the log file or output to the console.
Defines message type. When writing to console or CMTrace.exe log format, it allows highlighting of message type. Options: 1 = Information (default), 2 = Warning (highlighted in yellow), 3 = Error (highlighted in red)
The source of the message being logged. Default is from $MyInvocation
: ScriptName:ScriptLineNumber
The heading for the portion of the script that is being executed. Default is from $MyInvocation
: Command {Arguments}
Choose whether to write a CMTrace.exe compatible log file or a Legacy text log file.
Set the directory where the log file will be saved.
Set the name of the log file.
Maximum file size limit for log file in megabytes (MB). Default is 10 MB.
Write the log message to the console.
Suppress writing log message to console on failure to write message to log file.
Return the message that was passed to the function
Specifies that the message is a debug message. Debug messages only get logged if -LogDebugMessage is set to $true.
Debug messages only get logged if this parameter is set to $true in the config XML file.
Date format, as expected by Get-Date -Format
. Default: 'yyyy-MM-dd'
Time format, as expected by Get-Date -Format
. Default: 'HH:mm:ss.fff'
Write-Log -Message "Installing patch MS15-031" -Source 'Add-Patch' -LogType 'CMTrace'
Write-Log -Message "Script is running on Windows 8" -Source 'Test-ValidOS' -LogType 'Legacy'
Originally taken from PSAppDeployToolkit.