Skip to content

Instantly share code, notes, and snippets.

@iqwirty
Created April 16, 2014 19:48
Show Gist options
  • Save iqwirty/10925738 to your computer and use it in GitHub Desktop.
Save iqwirty/10925738 to your computer and use it in GitHub Desktop.
Writes a logging message to the console and to a file.
Function WriteLog
{
# Writes a logging message to the console and to a file. Assumes
# a variable called $logPath has already been initialized
# globally.
Param (
[string]$Message
)
$timestamp = Get-Date -Format "yyyy-MM-dd hh:mm:ss"
$timestampedMessage = "$timestamp $message"
Write-Host $timestampedMessage
$timestampedMessage | Out-File $logPath -Append
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment