Example
$Logfile = "C:\test\$(gc env:computername).log"
Function LogWrite
{
Param ([string]$logstring)
Add-content $Logfile -value $logstring
}
LogWrite "test logging is working?"
I am going to writesimpel template for logging which will five major steps.
Log-Start: Creates the .log file and initialises the log with date and time, etc
Log-Write: Writes a informational line to the log
Log-Error: Writes an error line to the log (formatted differently)
Log-Finish: Completes the log and writes stop date and time
Log-Email: Emails the content of the log
http://9to5it.com/powershell-logging-function-library/