Introduction
Recently, we came across an interesting bug that had been around for awhile (http://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=315875). If you do the following:
Start-Transcript
ipconfig
Stop-Transcript
If you look at the transcript, you’ll see that the output of ipconfig was not captured.
Why is this happening?
PowerShell recognizes that ipconfig is a native console application. Since many of these applications do direct writes to the console buffer (i.e. more.com, edit.com etc.), we don’t direct the output handles. Because of that, we can’t capture their output directly. This renders the transcription framework ineffective because the Out-Default cmdlet is unable to capture anything from ipconfig.
How can we work around it?
The workaround is actually quite simple. All you have to do is to pipe the output from ipconfig.exe to Out-Default.
Start-Transcript
ipconfig | Out-Default
Stop-Transcript
Tianjie (James) Wei [MSFT]
Software Design Engineer
Windows PowerShell Team
0 comments