![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | RE: How can I get pipeline output if Invoke throws??? I hope someone can correct me but I think this is similar to the following { } | % { } | ... | % { throw "help" } | ... My understanding is all information is lost if an exception is thrown within a pipeline. I guess this is an argument for non-terminating errors uh? One idea the help for Invoke does say you can moniter the state of the pipeline but its not obvious to me whether this will signal intermediary results. Here is the outline I suppose they could have made listening to this event more complex but I'm not sure how. 1) Register this event handler which will populate the PipelineStateEventArgs class when signaled http://msdn.microsoft.com/en-us/libr...ed(VS.85).aspx Pipeline.StateChanged 2) The PipelineStateInfo property of the PipelineStateEventArgs class returns a PipelineStateInfo class that you will need http://msdn.microsoft.com/en-us/libr...rs(VS.85).aspx 3) The PipelineStateInfo class has a property state which returns a PipelineState enumeration http://msdn.microsoft.com/en-us/libr...rs(VS.85).aspx 4) You are finally there. The PipelineState enumeration has the current state. http://msdn.microsoft.com/en-us/libr...te(VS.85).aspx PipelineState Enumeration btw is this for a script or C#? I'm curious a the Pipeline class is the same as the Powershell pipe that us scriptors are used to. I can see why this would be necessary for C# but I don't know the advantage in a script is the reason I ask. bob "CodeSlinger" wrote: Quote: > When I call Invoke on the pipeline, I get all my output fine as long as there > are no errors. If there is an error anywhere in the script, pipeline.Invoke > throws an exception which I can catch and I can even find the offending > cmdlet name but what I cannot figure out is how to get output for the cmdlets > in the script that ran OK prior to the offending cmdlet. Am hoping someone > knows how to do this! Thanks, Dave |
My System Specs![]() |
| | #2 (permalink) |
| | RE: How can I get pipeline output if Invoke throws??? It was difficult to find the information in a usable format but I discovered if you use add Out-Default command to the pipleline the errors can be merged with the output delivered to the host and so nothing is thrown. Thanks, Dave "Bob Landau" wrote: Quote: > I hope someone can correct me but I think this is similar to the following > > { } | % { } | ... | % { throw "help" } | ... > > My understanding is all information is lost if an exception is thrown within > a pipeline. I guess this is an argument for non-terminating errors uh? > > One idea the help for Invoke does say you can moniter the state of the > pipeline but its not obvious to me whether this will signal intermediary > results. > > Here is the outline I suppose they could have made listening to this event > more complex but I'm not sure how. > > 1) Register this event handler which will populate the > PipelineStateEventArgs class when signaled > http://msdn.microsoft.com/en-us/libr...ed(VS.85).aspx Pipeline.StateChanged > > 2) The PipelineStateInfo property of the PipelineStateEventArgs class > returns a PipelineStateInfo class that you will need > http://msdn.microsoft.com/en-us/libr...rs(VS.85).aspx > > 3) The PipelineStateInfo class has a property state which returns a > PipelineState enumeration > http://msdn.microsoft.com/en-us/libr...rs(VS.85).aspx > > 4) You are finally there. The PipelineState enumeration has the current > state. > > http://msdn.microsoft.com/en-us/libr...te(VS.85).aspx PipelineState Enumeration > > > btw is this for a script or C#? I'm curious a the Pipeline class is the same > as the Powershell pipe that us scriptors are used to. I can see why this > would be necessary for C# but I don't know the advantage in a script is the > reason I ask. > > > bob > > "CodeSlinger" wrote: > Quote: > > When I call Invoke on the pipeline, I get all my output fine as long as there > > are no errors. If there is an error anywhere in the script, pipeline.Invoke > > throws an exception which I can catch and I can even find the offending > > cmdlet name but what I cannot figure out is how to get output for the cmdlets > > in the script that ran OK prior to the offending cmdlet. Am hoping someone > > knows how to do this! Thanks, Dave |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| unwanted output while accessing pipeline in a PS script | PowerShell | |||
| How can I redirect output from Invoke-Expression ? | PowerShell | |||
| Pipeline input problems using Get-ChildItem and Invoke-Item | PowerShell | |||
| log output from invoke-expression | PowerShell | |||
| Validation needed: Tabular output throws OutofMemoryException errors with Out-File -Width 0x7fffffff | PowerShell | |||