Professional Documents
Culture Documents
About Format - ps1xml - Help
About Format - ps1xml - Help
about_Format.ps1xml
SHORT DESCRIPTION
The Format.ps1xml files in Windows PowerShell define the default display
of objects in the Windows PowerShell console. You can create your own
Format.ps1xml files to change the display of objects or to define default
displays for new object types that you create in Windows PowerShell.
LONG DESCRIPTION
The Format.ps1xml files in Windows PowerShell define the default display
of objects in Windows PowerShell. You can create your own Format.ps1xml
files to change the display of objects or to define default displays
for new object types that you create in Windows PowerShell.
The formatting affects the display only. It does not affect which object
properties are passed down the pipeline or how they are passed.
Certificate.Format.ps1xml
Objects in the Certificate store, such as X.509 certificates and
certificate stores.
DotNetTypes.Format.ps1xml
Other .NET Framework types, such as CultureInfo, FileVersionInfo,
and EventLogEntry objects.
FileSystem.Format.ps1xml
File system objects, such as files and directories.
Help.Format.ps1xml
Help views, such as detailed and full views, parameters, and
examples.
PowerShellCore.format.ps1xml
Objects generated by Windows PowerShell core cmdlets, such as
Get-Member and Get-History.
PowerShellTrace.format.ps1xml
Trace objects, such as those generated by the Trace-Command cmdlet.
Registry.format.ps1xml
Registry objects, such as keys and entries.
To create a new file, copy an existing Format.ps1xml file. The new file
can have any name, but it must have a .ps1xml file name extension. You
can place the new file in any directory that is accessible to Windows
PowerShell, but it is useful to place the files in the Windows PowerShell
installation directory ($pshome) or in a subdirectory of the installation
directory.
To change the formatting of a current view, locate the view in the
formatting file, and then use the tags to change the view. To create a
view for a new object type, create a new view, or use an existing view
as a model. (The tags are described in the next section of this topic.)
You can then delete all the other views in the file so that the changes
are obvious to anyone examining the file.
When you have saved the changes, use the Update-FormatData cmdlet to add
the new file to your Windows PowerShell session. If you want your view
to take precedence over a view defined in the built-in files, use the
PrependData parameter of Update-FormatData. Update-FormatData affects
only the current session. To make the change to all future sessions, add
the Update-FormatData command to your Windows PowerShell profile.
The first step is to find the Format.ps1xml file that contains the
current view of the culture objects. The following Select-String command
finds the file:
<View>
<Name>System.Globalization.CultureInfo</Name>
<ViewSelectedBy>
<TypeName>Deserialized.System.Globalization.CultureInfo</TypeName>
<TypeName>System.Globalization.CultureInfo</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader/>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>LCID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>DisplayName</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
Delete the remainder of the file, except for the opening <?XML>,
<Configuration>, and <ViewDefinitions> tags and the closing
<ViewDefintions> and <Configuration> tags. You must also delete the
digital signature whenever you change the file.
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>System.Globalization.CultureInfo</Name>
<ViewSelectedBy>
<TypeName>Deserialized.System.Globalization.CultureInfo</T
ypeName>
<TypeName>System.Globalization.CultureInfo</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader/>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>LCID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>DisplayName</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
Next, create a new column for the Calendar property by adding a new set
of <TableColumnHeader> tags. The value of the Calendar property can be
long, so a value of 45 characters is used, as follows:
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>45</Width>
</TableColumnHeader>
<TableColumnHeader/>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>LCID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Calendar</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>DisplayName</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
After saving the file and closing it, use an Update-FormatData command,
such as the following command, to add the new format file to the current
session. The command uses the PrependData parameter to place the new file
in a higher precedence order than the original file. (For more
information about Update-FormatData, type "get-help update-formatdata".)
To test the change, type "get-culture", and then review the output,
which includes the Calendar property.
C:\PS> get-culture
LCID Name Calendar DisplayName
---- ---- -------- -----------
1033 en-US System.Globalization.GregorianCalendar English (United States)
<Name>
The <Name> tag identifies the name of the view.
<ViewSelectedBy>
The <ViewSelectedBy> tag specifies the object type or types to
which the view applies.
<GroupBy>
The <GroupBy> tag specifies how items in the view will be
combined in groups.
<TableControl>
<ListControl>
<WideControl>
<ComplexControl>
These tags contain the tags that specify how each item will be
displayed.
The <ViewSelectedBy> tag can contain a <TypeName> tag for each object
type to which the view applies. Or, it can contain a <SelectionSetName>
tag that references a selection set that is defined elsewhere by using
a <SelectionSet> tag.
Update-FormatData
To load your Format.ps1xml files into a Windows PowerShell session, use
the Update-FormatData cmdlet. If you want the views in your file to
take precedence over the views in the built-in Format.ps1xml file, use
the PrependData parameter of Update-FormatData. Update-FormatData affects
only the current session. To make the change to all future sessions, add
the Update-FormatData command to your Windows PowerShell profile.
<DefaultDisplayProperty>
<DefaultDisplayPropertySet>
<DefaultKeyPropertySet>
FormatFileLoading
UpdateFormatData
FormatViewBinding
get-help trace-command
get-help get-tracesource
SEE ALSO
Update-FormatData
Trace-Command
Get-TraceSource