Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Save the output of powershell script

$
0
0

Here is code I use. The if($Host.Name…) will start the transcripting only if not running in the ISE, since ISE does not support transcript files.

$now=Get-Date -format "yyyyMMdd_HHmmss"

if ($Host.Name -ne "Windows PowerShell ISE Host")
{
$TranscriptFile = $ROOT + "LOGS\" + $MyInvocation.MyCommand.Name.Replace(".ps1", "") + "_$now.log"
Start-Transcript -Path $TranscriptFile
}
...
...
if ($Host.Name -ne "Windows PowerShell ISE Host")
{
Stop-Transcript
}


Viewing all articles
Browse latest Browse all 13067

Trending Articles