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
@@ -127,12 +127,11 @@ view of the culture objects. The following `Select-String` command finds the
127127file:
128128
129129``` powershell
130- $Parms = @{
131- Path = "$PSHOME\*Format.ps1xml"
132- Pattern = " System.Globalization.CultureInfo"
130+ $selectParams = @{
131+ Path = "$PSHOME\*Format.ps1xml"
132+ Pattern = ' System.Globalization.CultureInfo'
133133}
134-
135- Select-String @Parms
134+ Select-String @selectParams
136135```
137136
138137``` Output
@@ -142,14 +141,18 @@ C:\Windows\System32\WindowsPowerShell\v1.0\DotNetTypes.format.ps1xml:115:
142141<TypeName>System.Globalization.CultureInfo</TypeName>
143142```
144143
145- This command reveals that the definition is in the ` DotNetTypes.Format .ps1xml `
144+ This command reveals that the definition is in the ` DotNetTypes.format .ps1xml `
146145file.
147146
148147The next command copies the file contents to a new file,
149148` MyDotNetTypes.Format.ps1xml ` .
150149
151150``` powershell
152- Copy-Item $PSHOME\DotNetTypes.format.ps1xml MyDotNetTypes.Format.ps1xml
151+ $copyParams = @{
152+ LiteralPath = "$PSHOME\DotNetTypes.format.ps1xml"
153+ Destination = '.\MyDotNetTypes.Format.ps1xml'
154+ }
155+ Copy-Item @copyParams
153156```
154157
155158Open the ` MyDotNetTypes.Format.ps1xml ` file in any XML or text editor, such as
@@ -292,7 +295,7 @@ higher precedence order than the original file. For more information, see
292295[ Update-FormatData] ( xref:Microsoft.PowerShell.Utility.Update-FormatData ) .
293296
294297``` powershell
295- Update-FormatData -PrependPath $HOME\Format\CultureInfo .Format.ps1xml
298+ Update-FormatData -PrependPath .\MyDotNetTypes .Format.ps1xml
296299```
297300
298301To test the change, type ` Get-Culture ` and review the output that includes the
@@ -434,25 +437,38 @@ The following sample creates a `Format-Table` custom view for the
434437` Get-ChildItem ` . The custom view is named ** MyGciView** and adds the
435438** CreationTime** column to the table.
436439
440+ Use ` Select-String ` to identify which ` Format.ps1xml ` file contains data for
441+ the type you're looking for.
442+
437443The custom view is created from an edited version of the
438444` FileSystem.Format.ps1xml ` file that's stored in ` $PSHOME ` on PowerShell 5.1.
439445
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.
446+ After the custom ` .ps1xml ` file is saved, use the ` Update-FormatData ` cmdlet to
447+ include the view in the current PowerShell session. Or, add the update command
448+ to your PowerShell profile if you need the view available in all PowerShell
449+ sessions.
450+
451+ For this example, the custom view must use the table format, otherwise,
452+ ` Format-Table ` fails.
443453
444454Use ` 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 ) .
455+ name, ** MyGciView ** , and format the table's output with the ** CreationTime **
456+ column. For an example of how the command is run, see [ Format-Table] [ 08 ] .
447457
448458``` powershell
449- $Parms = @{
450- Path = "$PSHOME\*Format .ps1xml"
451- Pattern = " System.IO.DirectoryInfo"
459+ $selectParams = @{
460+ Path = "$PSHOME\*format .ps1xml"
461+ Pattern = ' System.IO.DirectoryInfo'
452462}
453- Select-String @Parms
454- Copy-Item $PSHOME\FileSystem.format.ps1xml .\MyFileSystem.Format.ps1xml
455- Update-FormatData -PrependPath $PSHOME\Format\MyFileSystem.Format.ps1xml
463+ Select-String @selectParams
464+
465+ $copyParams = @{
466+ LiteralPath = "$PSHOME\FileSystem.format.ps1xml"
467+ Destination = '.\MyFileSystem.Format.ps1xml'
468+ }
469+ Copy-Item @copyParams
470+
471+ Update-FormatData -PrependPath .\MyFileSystem.Format.ps1xml
456472```
457473
458474> [ !NOTE]
@@ -585,6 +601,6 @@ Update-FormatData -PrependPath $PSHOME\Format\MyFileSystem.Format.ps1xml
585601
586602[ 05 ] : xref:Microsoft.PowerShell.Utility.Trace-Command
587603[ 06 ] : xref:Microsoft.PowerShell.Utility.Get-TraceSource
588-
604+ [ 08 ] : xref:Microsoft.PowerShell.Utility.Format-Table
589605[ 09 ] : /powershell/scripting/developer/format/format-schema-xml-reference
590606[ 10 ] : /powershell/scripting/developer/format/writing-a-powershell-formatting-file
0 commit comments