Home Dashboard Directory Help
Search

Unable to capture ALL session output into a transcript by xkrissx


Status: 

Closed
 as Won't Fix Help for as Won't Fix


35
0
Sign in
to vote
Type: Bug
ID: 315875
Opened: 12/6/2007 7:01:16 AM
Access Restriction: Public
3
Workaround(s)
view
10
User(s) can reproduce this bug

Description

This issue was first reported by me in the windows.powershell newsgroup and 'Jeffrey P. Snover[MSFT]' suggested that I submit a bug report for it.

Start-transcript is supposed to log ALL output from the powershell session. However, if you call an executable from within your powershell session, the output will be visible in the window but won't be recorded in the transcript.

Problem has been found in PowerShell 1.0. Additional feedback by another user also confirms the presence of this problem in CTP 2.0.
Details
Sign in to post a comment.
Posted by Microsoft on 8/25/2012 at 5:21 PM
We've made some improvements in PowerShell 3.0 in allowing the various streams to be redirected (pipeline, error, warning, verbose, debug, etc.). However, we've decided not to invest in being able to log the output from native cmdline tools due to the high cost and technical complexities involved. We'll continue to work on improving cmdlet coverage for native cmdlet tools with the highest usage.
Posted by Microsoft Connect on 1/29/2010 at 2:08 PM
Your bug has not been fixed in PowerShell 2.0. However we have kept the bug active for next version
Posted by Microsoft Connect on 1/29/2010 at 2:04 PM
Your bug has not been fixed in PowerShell 2.0. However we have kept the bug active for next version
Posted by Microsoft Connect on 1/29/2010 at 2:00 PM
Your bug has not been fixed in PowerShell 2.0. However we have kept the bug active for next version
Posted by Microsoft Connect on 1/29/2010 at 1:55 PM
Your bug has not been fixed in PowerShell 2.0. However we have kept the bug active for next version
Posted by fatcat1111 on 10/8/2009 at 2:47 PM
Or at least add a switch, allowing all output to be captured to the transcript log. That would make this cmdlet truly useful.
Sign in to post a workaround.
Posted by Andrei Rubaniuk on 4/9/2013 at 11:48 PM
Here is the workaround to capture both STDOUT and STDERR to transcript:

robocopy.exe C:\ D:\ readme.txt 2>&1 | out-host

Full PowerShell script here: <a href="http://www.rubaniuk.com/?p=113" target="_blank">http://www.rubaniuk.com/?p=113</a>
Posted by Tom S. Holt on 4/2/2010 at 8:03 AM
How about this.

Wanted to share a way to capture all output and handle each stream separately. Below is a simple script on how you can do this. I use the job object in PS 2.0 to accomplish this. Note: this is designed for non-interactive scenarios like scheduled tasks. I inlcuded PowerShell commands and the IPCONFIG which is not a native PowerShell command. Works like a champ. In fact, you can actually check the job status and send an e-mail accordingly. You could include an exception in the body of the e-mail in case the job fails since you have access to the separate error stream. I guess there is no need for a writing a custom PowerShell host if you want to direct output to different sources.

$testScript = `
{
    $VerbosePreference = "Continue"
    $ErrorActionPreference = "Continue"
    $WarningPreference = "Continue"
    $DebugPreference = "Continue"
    Write-Verbose "verbose 1"
    Write-Verbose "verbose 2"
    Write-Verbose "verbose 3"
    Write-Error "an error 1"
    Write-Error "an error 2"
    Write-Error "an error 3"
    Write-Warning "a warning 1"
    Write-Warning "a warning 2"
    Write-Warning "a warning 3"
    Write-Debug "debug string 1"
    Write-Debug "debug string 2"
    Write-Debug "debug string 3"
    Write-Output "output 1"
    Write-Output "output 2"
    Write-Output "output 3"
    "output 4"
    Get-Process
    ipconfig
}

$job = Start-Job -Name "MessageTest" -ScriptBlock $testScript
Wait-Job -Job $job -TimeOut -1
foreach ($jobResult in $job.ChildJobs)
{
$jobResult.Output | Out-Host | Write-Host
$jobResult.Verbose | ForEach-Object -Process {$_.Message | Write-Host}
$jobResult.Warning | ForEach-Object -Process {$_.Message | Write-Host}
$jobResult.Debug | ForEach-Object -Process {$_.Message | Write-Host}
$jobResult.Error | ForEach-Object -Process {$_ | Out-Host | Write-Host}
}
Posted by Greg Bray on 3/5/2010 at 12:30 PM
You can sometimes pipe the output of the executable to Out-Host to make it appear in the transcript. Example:

& myprogram.exe -arguments | out-host

See line 082 on this script for calling 7Zip from Powershell:

http://codeblog.theg2.net/2010/02/powershell-7-zip-amazon-s3-upload.html