http://community.idera.com/powershell/powertips/b/tips/posts/script-logging-made-easy http://community.idera.com/powershell/powertips/b/tips/posts/using-windows-eventlog-for-script-logging
#requires -runasadministrator
New-EventLog -LogName PSScriptLog -Source Logon, Installation, Misc, Secret
Limit-EventLog -LogName PSScriptLog -MaximumSize 10MB -OverflowAction OverwriteAsNeeded
#or
Write-EventLog -LogName PSScriptLog -Source Logon -EntryType Warning -EventId 123 -Message "Problem in script $PSCommandPath"
# add this: ############################
$logFile = "$PSScriptRoot\mylog.txt"
Start-Transcript -Path $logFile -Append
#########################################
"Hello"
($a = Get-Service)
"I received $($a.Count) services."
Write-Host "Watch out: direct output will not be logged!"
# end logging ###########################
Stop-Transcript
#########################################po