Created
June 26, 2017 21:05
-
-
Save markwragg/f3ac7bd6098dec485e8f11c1fd056fad to your computer and use it in GitHub Desktop.
Simple PowerShell logging function with timestamp, redirects messages to a log file and the verbose stream.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Write-Log { | |
Param( | |
$Message, | |
$Path = "$env:USERPROFILE\log.txt" | |
) | |
function TS {Get-Date -Format 'hh:mm:ss'} | |
"[$(TS)]$Message" | Tee-Object -FilePath $Path -Append | Write-Verbose | |
} | |
Write-Log 'Some message' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment