Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Native command redirection in Monad (MSH)

Reply
 
Old 07-13-2007   #1 (permalink)
Joey


 
 

Native command redirection in Monad (MSH)

How do I redirect the output from the call of a native command to my own
PSHost application? I'm able to recieve the output from cmdlets but when
calling a native command like tf.exe a new window is spawned and the output
is not redirected. The

NotifyBeginApplication() method is being called in my host application, but
there are no parameters for me to hook onto the newly spawned process and
redirect it.

Here is an example:

$TFExecutablePath = "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE"

function DeleteWorkspace([String]$Name, [String]$TeamFoundationServerUrl)
{
$ErrorActionPreference = "stop"
# delete the workspace
& $TFExecutablePath\.\tf.exe workspace /delete $Name
/s:$TeamFoundationServerUrl /noprompt
# spit out the exit code
write-Host "ExitCode: $lastexitcode"
}

DeleteWorkspace "Test" "MyServer"

Since I'm running an external executable in this function I want to see the
output from the call to it and the following statement is what I'm expecting
to be redirected to my host application.

TF14061: The workspace Test;domain\user does not exist.



My System SpecsSystem Spec
Old 07-13-2007   #2 (permalink)
dreeschkind


 
 

RE: Native command redirection in Monad (MSH)

Maybe this will help you:
http://msdn2.microsoft.com/en-us/lib...ardoutput.aspx

Also notice that Monad is now called Windows PowerShell.
http://en.wikipedia.org/wiki/Windows_PowerShell

--
greetings
dreeschkind

"Joey" wrote:

> How do I redirect the output from the call of a native command to my own
> PSHost application? I'm able to recieve the output from cmdlets but when
> calling a native command like tf.exe a new window is spawned and the output
> is not redirected. The
>
> NotifyBeginApplication() method is being called in my host application, but
> there are no parameters for me to hook onto the newly spawned process and
> redirect it.
>
> Here is an example:
>
> $TFExecutablePath = "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE"
>
> function DeleteWorkspace([String]$Name, [String]$TeamFoundationServerUrl)
> {
> $ErrorActionPreference = "stop"
> # delete the workspace
> & $TFExecutablePath\.\tf.exe workspace /delete $Name
> /s:$TeamFoundationServerUrl /noprompt
> # spit out the exit code
> write-Host "ExitCode: $lastexitcode"
> }
>
> DeleteWorkspace "Test" "MyServer"
>
> Since I'm running an external executable in this function I want to see the
> output from the call to it and the following statement is what I'm expecting
> to be redirected to my host application.
>
> TF14061: The workspace Test;domain\user does not exist.
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
native command messages/errors PowerShell
old Monad Script fails when run in RC1 Powershell PowerShell
Monad/Powershell Extensibility PowerShell
Monad / PowerShell / Exchange 2007 PowerShell
Monad Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46