Logging to a text file
function WriteLog(
[string] $Message=$(throw '$message is required'))
{
#Example WriteLog("OMG Blah blah blah")
$DateStamp = Get-Date -format yyyyMdd
$Username=$env:USERNAME
$logfile= $LogDir + $DateStamp + "_BlahScript_Log.txt"
"$(Get-date) $Username $Message "| Out-File -Append -FilePath $logfile
}
|
|