Skip to content

Instantly share code, notes, and snippets.

@markwragg
markwragg / Write-Log.ps1
Created June 26, 2017 21:05
Simple PowerShell logging function with timestamp, redirects messages to a log file and the verbose stream.
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
}