To log your entire powershell session to a file you can use the start-transcript and stop-transcript commands.
$mypowershellapplicationdir = "c:\myapp" $logfiledate = (get-date).tostring("yyyyMMddHHssmm") + ".txt" start-transcript -path $mypowershellapplicationdir\logs\$logfiledate
Stop-transcript will automatically be done when leaving powershell.