header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Formatting default cmdlet output
Last Post 22 May 2008 12:31 PM by Don Jones. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
JimMcGillUser is Offline
New Member
New Member
Posts:3
Avatar

--
24 Apr 2008 08:22 AM

    I've written a custom cmdlet that chews through a binary file and creates well behaved PSObjects that "where" and cmdlets like "FT" operate on correctly. But the default output, if I don't pipe my output into something else, is FL dumping all the data. Does the job but isn't succinct. I’d like to define a default custom output format. I see some evidence that this is an XML file, but I haven’t been able to find any description of how to hook it up in the current version of PowerShell  (there is some discussion about doing that with Monad, but that doesn’t seem to work anymore). Anybody know of a full example out there on the web that discusses how you hook the XML up, where you put it, and what xml keys are expected?

    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1647
    Avatar

    --
    27 Apr 2008 05:52 PM
    http://msdn2.microsoft.com/en-us/li...S.85).aspx

    Basically you create your custom .ps1xml file, then use the update-typedata cmdlet to apply the formatting.

    Let me know if you need a complete example...
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    Don JonesUser is Offline
    PowerShell MVP
    Basic Member
    Basic Member
    Posts:134
    Avatar

    --
    22 May 2008 12:31 PM
    Although you can't really do default formatting for a PSObject. Your cmdlet needs to define a new class and output objects of that class. This is all because the formatting subsystem relies on the object's type name to apply formatting; if you're using a generic PSObject it can't be differentiated from all the other things that output PSObject. If you use a custom type, the formatting system can distinguish it.

    "Windows PowerShell: TFM, 2nd Edition" has a detailed chapter on the formatting XML files, how to load them into the shell, etc.
    - Don Jones
    www.ConcentratedTech.com
    Subscribe (RSS) or visit for weekly PowerShell tips and lessons
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer