@@ -32,6 +32,10 @@ Return the message that was passed to the function
3232Specifies that the message is a debug message. Debug messages only get logged if -LogDebugMessage is set to $true.
3333. PARAMETER LogDebugMessage
3434Debug messages only get logged if this parameter is set to $true in the config XML file.
35+ . PARAMETER LogDateFormat
36+ Date format, as expected by `Get-Date -Format`. Default: 'yyyy-MM-dd'
37+ . PARAMETER LogTimeFormat
38+ Time format, as expected by `Get-Date -Format`. Default: 'HH:mm:ss.fff'
3539. EXAMPLE
3640Write-Log -Message "Installing patch MS15-031" -Source 'Add-Patch' -LogType 'CMTrace'
3741. EXAMPLE
@@ -81,7 +85,11 @@ Function Write-Log {
8185 [Parameter (Mandatory = $false , Position = 11 )]
8286 [switch ]$DebugMessage = $false ,
8387 [Parameter (Mandatory = $false , Position = 12 )]
84- [boolean ]$LogDebugMessage = $false
88+ [boolean ]$LogDebugMessage = $false ,
89+ [Parameter (Mandatory = $false , Position = 13 )]
90+ [string ]$LogDateFormat = ' yyyy-MM-dd' ,
91+ [Parameter (Mandatory = $false , Position = 14 )]
92+ [string ]$LogTimeFormat = ' HH:mm:ss.fff'
8593 )
8694
8795 Begin {
@@ -111,8 +119,8 @@ Function Write-Log {
111119 }
112120
113121 # Initialize the date/time variables
114- [string ]$LogTime = (Get-Date - Format HH:mm:ss.fff ).ToString()
115- [string ]$LogDate = (Get-Date - Format MM - dd - yyyy ).ToString()
122+ [string ]$LogTime = (Get-Date - Format $LogTimeFormat ).ToString()
123+ [string ]$LogDate = (Get-Date - Format $LogDateFormat ).ToString()
116124 If (-not (Test-Path - Path ' variable:LogTimeZoneBias' )) {
117125 [int32 ]$script :LogTimeZoneBias = [System.TimeZone ]::CurrentTimeZone.GetUtcOffset([datetime ]::Now).TotalMinutes
118126 }
0 commit comments