liveBook · Manning

Format file

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

A format file is a PowerShell XML configuration file that defines how specific object types are displayed.

A format file is a PowerShell XML configuration file that controls how particular object types appear in the console. It supplies display details such as column headers, widths, alignment, views, and selected properties. section 11.2

You can inspect and extend formatting definitions by:

  • Finding the object’s complete type name with Get-Member. section 11.2
  • Searching an installed .format.ps1xml file for that type and its table view. section 11.2
  • Loading custom XML with Update-TypeData. section 11.2

Choose default properties for Uri objects

An XML definition for System.Uri can set the default display properties to Scheme, Host, Port, AbsoluteUri, and IsFile. Save it as Uri.Types.ps1xml, run Update-TypeData -Path /tmp/Uri.Types.ps1xml, and display a URI to see the selected columns. section 11.2

<?xml version="1.0" encoding="utf-8" ?>
<Types>
  <Type>
    <Name>System.Uri</Name>
    <Members>
      <MemberSet>
        <Name>PSStandardMembers</Name>
        <Members>
          <PropertySet>
            <Name>DefaultDisplayPropertySet</Name>
            <ReferencedProperties>
              <Name>Scheme</Name>
              <Name>Host</Name>
              <Name>Port</Name>
              <Name>AbsoluteUri</Name>
              <Name>IsFile</Name>
            </ReferencedProperties>
          </PropertySet>
        </Members>
      </MemberSet>
    </Members>
  </Type>
</Types>

Inspect the XML structure used to define a type’s default display property set. section 11.2

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains display metadata, XML property sets, type lookup, and loading custom definitions, without detailing the full formatting system.
Examples
Uses process output, PSReadLine key handlers, and a custom System.Uri property set.
What you can do after
Apply custom display properties by writing XML and loading it with Update-TypeData.
How it connects
Connects object types with Get-Member, Get-FormatData, XML, and Update-TypeData.

Also explained in

Compare how 2 books explain format file →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.