#Put this at the front of powershell scripts to log in temp..

# Get log path. Will log to Task Sequence log folder if the script is running in a Task Sequence 
 # Otherwise log to \\windows\\temp

    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
    $logPath = $tsenv.Value("LogPath")
    Write-Host "This script is not running in a task sequence"
    $logPath = $env:windir + "\\temp"
$logFile = "$logPath\\$($myInvocation.MyCommand).log"

# Start logging

Start-Transcript $logFile
Write-Host "Logging to $logFile"