View Single Post
  #1 (permalink)  
Old December 17th, 2008, 01:42 AM
Mike Shepard Mike Shepard is offline
Registered User
 
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?
Reply With Quote