11---
22description : The `Format.ps1xml` files in PowerShell define the default display of objects in the 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 PowerShell.
33Locale : en-US
4- ms.date : 04/25/2022
4+ ms.date : 12/26/2025
55online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_format.ps1xml?view=powershell-5.1&WT.mc_id=ps-gethelp
66schema : 2.0.0
77title : about_Format.ps1xml
@@ -88,7 +88,7 @@ headers, and the properties that are displayed in the body of the view. The
8888format in ` Format.ps1xml ` files is applied just before the data is presented to
8989the user.
9090
91- ## CREATING NEW FORMAT.PS1XML FILES
91+ ## Creating new Format.ps1xml files
9292
9393The ` .ps1xml ` files that are installed with PowerShell are digitally signed to
9494prevent tampering because the formatting can include script blocks. To change
@@ -98,9 +98,7 @@ session.
9898
9999To create a new file, copy an existing ` Format.ps1xml ` file. The new file can
100100have any name, but it must have a ` .ps1xml ` file name extension. You can place
101- the new file in any directory that is accessible to PowerShell, but it's useful
102- to place the files in the PowerShell installation directory (` $PSHOME ` ) or in a
103- subdirectory of the installation directory.
101+ the new file in any directory that is accessible to PowerShell.
104102
105103To change the formatting of a current view, locate the view in the formatting
106104file, and then use the tags to change the view. To create a view for a new
@@ -127,12 +125,11 @@ view of the culture objects. The following `Select-String` command finds the
127125file:
128126
129127``` powershell
130- $Parms = @{
131- Path = "$PSHOME\*Format.ps1xml"
132- Pattern = " System.Globalization.CultureInfo"
128+ $selectParams = @{
129+ Path = "$PSHOME\*Format.ps1xml"
130+ Pattern = ' System.Globalization.CultureInfo'
133131}
134-
135- Select-String @Parms
132+ Select-String @selectParams
136133```
137134
138135``` Output
@@ -142,14 +139,20 @@ C:\Windows\System32\WindowsPowerShell\v1.0\DotNetTypes.format.ps1xml:115:
142139<TypeName>System.Globalization.CultureInfo</TypeName>
143140```
144141
145- This command reveals that the definition is in the ` DotNetTypes.Format .ps1xml `
142+ This command reveals that the definition is in the ` DotNetTypes.format .ps1xml `
146143file.
147144
148- The next command copies the file contents to a new file,
149- ` MyDotNetTypes.Format.ps1xml ` .
145+ The following commands copy the file contents to a new file named
146+ ` MyDotNetTypes.Format.ps1xml ` in a newly created ` $HOME\Format ` directory .
150147
151148``` powershell
152- Copy-Item $PSHOME\DotNetTypes.format.ps1xml MyDotNetTypes.Format.ps1xml
149+ New-Item -Path $HOME\Format -ItemType Directory -Force
150+
151+ $copyParams = @{
152+ LiteralPath = "$PSHOME\DotNetTypes.format.ps1xml"
153+ Destination = "$HOME\Format\MyDotNetTypes.Format.ps1xml"
154+ }
155+ Copy-Item @copyParams
153156```
154157
155158Open the ` MyDotNetTypes.Format.ps1xml ` file in any XML or text editor, such as
@@ -289,10 +292,10 @@ the current PowerShell session.
289292
290293This example uses the ** PrependPath** parameter to place the new file in a
291294higher precedence order than the original file. For more information, see
292- [ Update-FormatData] ( xref:Microsoft.PowerShell.Utility.Update-FormatData ) .
295+ [ Update-FormatData] [ 03 ] .
293296
294297``` powershell
295- Update-FormatData -PrependPath $HOME\Format\CultureInfo .Format.ps1xml
298+ Update-FormatData -PrependPath $HOME\Format\MyDotNetTypes .Format.ps1xml
296299```
297300
298301To test the change, type ` Get-Culture ` and review the output that includes the
@@ -310,8 +313,8 @@ LCID Name Calendar DisplayName
310313
311314## The XML in Format.ps1xml files
312315
313- The full schema definition can be found in [ Format.xsd] ( https://github.com/ PowerShell/PowerShell/blob/master/src/Schemas/Format.xsd )
314- in the PowerShell source code repository on GitHub.
316+ The full schema definition can be found in [ Format.xsd] [ 04 ] in the PowerShell
317+ source code repository on GitHub.
315318
316319The ** ViewDefinitions** section of each ` Format.ps1xml ` file contains the
317320` <View> ` tags that define each view. A typical ` <View> ` tag includes the
@@ -376,13 +379,13 @@ that the `<ListControl>` tag is intended to display.
376379### WideControl tag
377380
378381The ` <WideControl> ` tag typically contains a ` <WideEntries> ` tag. The
379- ` <WideEntries> ` tag contains one or more ` <WideEntry> ` tags. A ` <WideEntry> ` tag
380- contains one ` <WideItem> ` tag.
382+ ` <WideEntries> ` tag contains one or more ` <WideEntry> ` tags. A ` <WideEntry> `
383+ tag contains one ` <WideItem> ` tag.
381384
382385A ` <WideItem> ` tag must include either a ` <PropertyName> ` tag or a
383- ` <ScriptBlock> ` tag. A ` <PropertyName> ` tag specifies the property to display at
384- the specified location in the view. A ` <ScriptBlock> ` tag specifies a script to
385- evaluate and display at the specified location in the view.
386+ ` <ScriptBlock> ` tag. A ` <PropertyName> ` tag specifies the property to display
387+ at the specified location in the view. A ` <ScriptBlock> ` tag specifies a script
388+ to evaluate and display at the specified location in the view.
386389
387390A ` <WideItem> ` tag can contain a ` <FormatString> ` tag that specifies how to
388391display the property.
@@ -396,7 +399,7 @@ multiple `<CustomEntry>` tags. Each `<CustomEntry>` tag contains a
396399formatting of the specified location in the view, including ` <Text> ` ,
397400` <Indentation> ` , ` <ExpressionBinding> ` , and ` <NewLine> ` tags.
398401
399- ## DEFAULT DISPLAYS IN TYPES.PS1XML
402+ ## Default displays in Types.ps1xml
400403
401404The default displays of some basic object types are defined in the
402405` Types.ps1xml ` file in the ` $PSHOME ` directory. The nodes are named
@@ -417,15 +420,12 @@ value of the **Name** parameter:
417420- FormatFileLoading
418421- FormatViewBinding
419422
420- For more information, see
421- [ Trace-Command] ( xref:Microsoft.PowerShell.Utility.Trace-Command ) and
422- [ Get-TraceSource] ( xref:Microsoft.PowerShell.Utility.Get-TraceSource ) .
423+ For more information, see [ Trace-Command] [ 05 ] and [ Get-TraceSource] [ 06 ] .
423424
424425## Signing a Format.ps1xml file
425426
426427To protect the users of your ` Format.ps1xml ` file, sign the file using a
427- digital signature. For more information, see
428- [ about_Signing] ( about_Signing.md ) .
428+ digital signature. For more information, see [ about_Signing] [ 07 ] .
429429
430430## Sample XML for a Format-Table custom view
431431
@@ -434,25 +434,38 @@ The following sample creates a `Format-Table` custom view for the
434434` Get-ChildItem ` . The custom view is named ** MyGciView** and adds the
435435** CreationTime** column to the table.
436436
437+ Use ` Select-String ` to identify which ` Format.ps1xml ` file contains data for
438+ the type you're looking for.
439+
437440The custom view is created from an edited version of the
438441` FileSystem.Format.ps1xml ` file that's stored in ` $PSHOME ` on PowerShell 5.1.
439442
440- After your custom ` .ps1xml ` file is saved, use ` Update-FormatData ` to include
441- the view in a PowerShell session. For this example, the custom view must use
442- the table format, otherwise, ` Format-Table ` fails.
443+ After the custom ` .ps1xml ` file is saved, use the ` Update-FormatData ` cmdlet to
444+ include the view in the current PowerShell session. Or, add the update command
445+ to your PowerShell profile if you need the view available in all PowerShell
446+ sessions.
447+
448+ For this example, the custom view must use the table format, otherwise,
449+ ` Format-Table ` fails.
443450
444451Use ` Format-Table ` with the ** View** parameter to specify the custom view's
445- name and format the table's output. For an example of how the command is run,
446- see [ Format-Table] ( xref:Microsoft.PowerShell.Utility.Format-Table ) .
452+ name, ** MyGciView ** , and format the table's output with the ** CreationTime **
453+ column. For an example of how the command is run, see [ Format-Table] [ 08 ] .
447454
448455``` powershell
449- $Parms = @{
450- Path = "$PSHOME\*Format .ps1xml"
451- Pattern = " System.IO.DirectoryInfo"
456+ $selectParams = @{
457+ Path = "$PSHOME\*format .ps1xml"
458+ Pattern = ' System.IO.DirectoryInfo'
452459}
453- Select-String @Parms
454- Copy-Item $PSHOME\FileSystem.format.ps1xml .\MyFileSystem.Format.ps1xml
455- Update-FormatData -PrependPath $PSHOME\Format\MyFileSystem.Format.ps1xml
460+ Select-String @selectParams
461+
462+ $copyParams = @{
463+ LiteralPath = "$PSHOME\FileSystem.format.ps1xml"
464+ Destination = "$HOME\Format\MyFileSystem.Format.ps1xml"
465+ }
466+ Copy-Item @copyParams
467+
468+ Update-FormatData -PrependPath $HOME\Format\MyFileSystem.Format.ps1xml
456469```
457470
458471> [ !NOTE]
@@ -582,9 +595,10 @@ Update-FormatData -PrependPath $PSHOME\Format\MyFileSystem.Format.ps1xml
582595[ 01 ] : xref:Microsoft.PowerShell.Utility.Get-FormatData
583596[ 02 ] : xref:Microsoft.PowerShell.Utility.Export-FormatData
584597[ 03 ] : xref:Microsoft.PowerShell.Utility.Update-FormatData
585-
598+ [ 04 ] : https://github.com/PowerShell/PowerShell/blob/master/src/Schemas/Format.xsd
586599[ 05 ] : xref:Microsoft.PowerShell.Utility.Trace-Command
587600[ 06 ] : xref:Microsoft.PowerShell.Utility.Get-TraceSource
588-
601+ [ 07 ] : about_Signing.md
602+ [ 08 ] : xref:Microsoft.PowerShell.Utility.Format-Table
589603[ 09 ] : /powershell/scripting/developer/format/format-schema-xml-reference
590604[ 10 ] : /powershell/scripting/developer/format/writing-a-powershell-formatting-file
0 commit comments