p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Windows PowerShell Programming ISBN: 978-0-470-17393-0 (http://p2p.wrox.com/forumdisplay.php?f=386)
-   -   getting formatted output in hosted powershell (http://p2p.wrox.com/showthread.php?t=71855)

Mike Shepard December 17th, 2008 01:42 AM

getting formatted output in hosted powershell
 
I've followed along with the examples in chapter 6 (hosting powershell in applications) and have a working app. I have a problem when trying to get the output of a pipeline like "dir | format-table". All of the examples show simply calling the ToString() method on each of the PSObjects in the collection returned (which works if you leave the format-table off), but the objects returned by the format-table cmdlet are apparently internal not-really-documented (couldn't find them in MSDN, for example) and don't implement anything for ToString() other than outputing the typename.

For example, I get the following:
Microsoft.PowerShell.Commands.Internal.Format.Form atStartData
Microsoft.PowerShell.Commands.Internal.Format.Grou pStartData
Microsoft.PowerShell.Commands.Internal.Format.Form atEntryData
Microsoft.PowerShell.Commands.Internal.Format.Form atEntryData
Microsoft.PowerShell.Commands.Internal.Format.Form atEntryData
Microsoft.PowerShell.Commands.Internal.Format.Form atEntryData
Microsoft.PowerShell.Commands.Internal.Format.Grou pEndData
Microsoft.PowerShell.Commands.Internal.Format.Form atEndData

I have grabbed these objects in a real powershell session (not in my app) and tried to figure out how to get anything resembling output out of them to no avail. Can you point me somewhere helpful?

marco.shaw January 8th, 2009 09:20 AM

RE: getting formatted output in hosted powershell
 
Quote:

Originally Posted by Mike Shepard (Post 231714)
I've followed along with the examples in chapter 6 (hosting powershell in applications) and have a working app. I have a problem when trying to get the output of a pipeline like "dir | format-table". All of the examples show simply calling the ToString() method on each of the PSObjects in the collection returned (which works if you leave the format-table off), but the objects returned by the format-table cmdlet are apparently internal not-really-documented (couldn't find them in MSDN, for example) and don't implement anything for ToString() other than outputing the typename.

For example, I get the following:
Microsoft.PowerShell.Commands.Internal.Format.Form atStartData
Microsoft.PowerShell.Commands.Internal.Format.Grou pStartData
Microsoft.PowerShell.Commands.Internal.Format.Form atEntryData
Microsoft.PowerShell.Commands.Internal.Format.Form atEntryData
Microsoft.PowerShell.Commands.Internal.Format.Form atEntryData
Microsoft.PowerShell.Commands.Internal.Format.Form atEntryData
Microsoft.PowerShell.Commands.Internal.Format.Grou pEndData
Microsoft.PowerShell.Commands.Internal.Format.Form atEndData

I have grabbed these objects in a real powershell session (not in my app) and tried to figure out how to get anything resembling output out of them to no avail. Can you point me somewhere helpful?

Format-Table is meant to be the last cmdlet used in a pipeline. Once you use Format-Table, you're basically stuck with the objects that are outputted, and you cannnot do any further manipulation of the objects that are returned.

Maybe you can share more details on what you're trying to accomplish?

absinha October 8th, 2009 03:42 AM

I too have the same problem. I am trying to display the objects returned from my cmdlet to the console. But inside the host I donot have any idea how to handle these formated table data objects which appear to be internal to the PS host.

Would be great if someone can clarify

Thanks

amandaboard October 8th, 2009 03:57 AM

Optical Mark Reader Scanner
 
NANHAO Optical Mark Reader (OMR Scanner) is a high speed data capture device which is mainly used for recognizing the filled datas in all kind of info-Forms. It’s highest reading speed can reach nearly 8000 info-Forms per hour (A4)
NANHAO Optical Mark Reader (OMR Scanner) has been largely used in all kind areas of high speed data processing, such as school examination, vote, transportation, human resources, fiscal taxation and finance and so on.


All times are GMT -4. The time now is 11:21 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.