Write-FormatView


|

Creates a format XML that will be used to display a type.

Format XML is used by Windows PowerShell to determine how objects are displayed.

Most items in PowerShell that come from built-in cmdlets make use of formatters in some
way or another. Write-FormatView simplifies the creation of formatting for a type.


You can format information in three major ways in PowerShell:
- As a table
- As a list
- As a custom action

Write-FormatView supports displaying information in any of these ways. This display
will be applied to any information that would be displayed to the user (or piped into
an Out- cmdlet) that has the typename you specify. A typename can be anything you like,
and it can be set in a short piece of PowerShell script:

$object.psObject.Typenames.Clear()
$null = $object.psObject.TypeNames.Add("MyTypeName").

Since it is so simple to change the type names, it's equally simple to make your own way to
display data, and to write functions that leverage the formatting system in PowerShell to help
you write the information. This can streamline your use of PowerShell, and open up many
new possibilities.

Type Name

One or more type names.

Property

One or more properties to include in the default type view.

Group By Property

If this is set, then the view will be grouped by a property

Wrap

If wrap is set, then items in the table can span multiple lines

Group Label

If this is set, then the view will be labeled with the value of this parameter. If this is not present and -GroupView is not present, the result of the script or property name will be used for the label

Group By Script

If this is set, then the view will be grouped by the result of a script block

Is Selection Set

If set, it will treat the type name as a selection set (a set of predefined types)

Auto Size

If set, the table will be autosized.

As List

If set, then the content will be rendered as a list

Indent

The indentation depth of the custom control

Action

The script block used to fill in the contents of a custom control. The script block can either be an arbitrary script, which will be run, or it can include a number of speicalized commands that will translate into parts of the formatter.