header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
PSObject formatting (types.ps1xml and format.ps1xml) directly from code
Last Post 25 Aug 2008 07:03 PM by halr9000. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
TeX HeXUser is Offline
New Member
New Member
Posts:1
Avatar

--
25 Aug 2008 11:18 AM

    I just wanted to share that I have created a small class that can create the XML needed for types.ps1xml and format.ps1xml directly from the code of your custom object by using attributes.

    For example:

            [xPSProperty(Default = true, Alias = "FullName") 

          public string Name

    Will result in an XML like this (sorry, the forum does not allow direct XML input so I can only show the paths inside the XML)

          DefaultDisplayProperty/FullName     

          DefaultDisplayPropertySet/FullName

    You can also generate the XML for the table view

            [xPSProperty(Default = true, Sequence = 1, Alias = "FullName", ColumnWidth = 30)]
            public string Name

     

          [xPSProperty(Sequence = 2, ColumnName = "Size (K)", ColumnRightAligned = true, ColumnScript = "[int]($_.Size / 1024)")]

            public int Size

     

    More examples, a detailed description and the source code is available at this address:

    http://texhex.blogspot.com/2008/08/...shell.html

     

    halr9000User is Offline
    PowerShell MVP, Site Admin
    Advanced Member
    Advanced Member
    Posts:565
    Avatar

    --
    25 Aug 2008 07:03 PM
    This is awesome work man!
    Community Director, PowerShellCommunity.org
    Co-host, PowerScripting Podcast
    Author, TechProsaic
    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