From 4ba57669ae48f2260467427b78e70dde8ce6db2b Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Fri, 26 Dec 2025 05:20:35 +0000 Subject: [PATCH 01/10] Fix 5.1 about_Format.ps1xml examples This fixes the wrong path used in both `Update-FormatData` examples. The paths used to initially create the custom formatting files are .\MyDotNetTypes.Format.ps1xml and .\MyFileSystem.Format.ps1xml. Before this change, Update-FormatData -PrependPath incorrectly pointed to $HOME\Format\CultureInfo.Format.ps1xml and $PSHOME\Format\MyFileSystem.Format.ps1xml. --- .../About/about_Format.ps1xml.md | 58 ++++++++++++------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 8e7518e6e313..2fa183012947 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -1,7 +1,7 @@ --- description: 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. Locale: en-US -ms.date: 04/25/2022 +ms.date: 12/26/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_format.ps1xml?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_Format.ps1xml @@ -127,12 +127,11 @@ view of the culture objects. The following `Select-String` command finds the file: ```powershell -$Parms = @{ - Path = "$PSHOME\*Format.ps1xml" - Pattern = "System.Globalization.CultureInfo" +$selectParams = @{ + Path = "$PSHOME\*Format.ps1xml" + Pattern = 'System.Globalization.CultureInfo' } - -Select-String @Parms +Select-String @selectParams ``` ```Output @@ -142,14 +141,18 @@ C:\Windows\System32\WindowsPowerShell\v1.0\DotNetTypes.format.ps1xml:115: System.Globalization.CultureInfo ``` -This command reveals that the definition is in the `DotNetTypes.Format.ps1xml` +This command reveals that the definition is in the `DotNetTypes.format.ps1xml` file. The next command copies the file contents to a new file, `MyDotNetTypes.Format.ps1xml`. ```powershell -Copy-Item $PSHOME\DotNetTypes.format.ps1xml MyDotNetTypes.Format.ps1xml +$copyParams = @{ + LiteralPath = "$PSHOME\DotNetTypes.format.ps1xml" + Destination = '.\MyDotNetTypes.Format.ps1xml' +} +Copy-Item @copyParams ``` Open 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 [Update-FormatData](xref:Microsoft.PowerShell.Utility.Update-FormatData). ```powershell -Update-FormatData -PrependPath $HOME\Format\CultureInfo.Format.ps1xml +Update-FormatData -PrependPath .\MyDotNetTypes.Format.ps1xml ``` To 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 `Get-ChildItem`. The custom view is named **MyGciView** and adds the **CreationTime** column to the table. +Use `Select-String` to identify which `Format.ps1xml` file contains data for +the type you're looking for. + The custom view is created from an edited version of the `FileSystem.Format.ps1xml` file that's stored in `$PSHOME` on PowerShell 5.1. -After your custom `.ps1xml` file is saved, use `Update-FormatData` to include -the view in a PowerShell session. For this example, the custom view must use -the table format, otherwise, `Format-Table` fails. +After the custom `.ps1xml` file is saved, use the `Update-FormatData` cmdlet to +include the view in the current PowerShell session. Or, add the update command +to your PowerShell profile if you need the view available in all PowerShell +sessions. + +For this example, the custom view must use the table format, otherwise, +`Format-Table` fails. Use `Format-Table` with the **View** parameter to specify the custom view's -name and format the table's output. For an example of how the command is run, -see [Format-Table](xref:Microsoft.PowerShell.Utility.Format-Table). +name, **MyGciView**, and format the table's output with the **CreationTime** +column. For an example of how the command is run, see [Format-Table][08]. ```powershell -$Parms = @{ - Path = "$PSHOME\*Format.ps1xml" - Pattern = "System.IO.DirectoryInfo" +$selectParams = @{ + Path = "$PSHOME\*format.ps1xml" + Pattern = 'System.IO.DirectoryInfo' } -Select-String @Parms -Copy-Item $PSHOME\FileSystem.format.ps1xml .\MyFileSystem.Format.ps1xml -Update-FormatData -PrependPath $PSHOME\Format\MyFileSystem.Format.ps1xml +Select-String @selectParams + +$copyParams = @{ + LiteralPath = "$PSHOME\FileSystem.format.ps1xml" + Destination = '.\MyFileSystem.Format.ps1xml' +} +Copy-Item @copyParams + +Update-FormatData -PrependPath .\MyFileSystem.Format.ps1xml ``` > [!NOTE] @@ -585,6 +601,6 @@ Update-FormatData -PrependPath $PSHOME\Format\MyFileSystem.Format.ps1xml [05]: xref:Microsoft.PowerShell.Utility.Trace-Command [06]: xref:Microsoft.PowerShell.Utility.Get-TraceSource - +[08]: xref:Microsoft.PowerShell.Utility.Format-Table [09]: /powershell/scripting/developer/format/format-schema-xml-reference [10]: /powershell/scripting/developer/format/writing-a-powershell-formatting-file From 4e5980716b1c7241bcff365b8acebb763c555727 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Fri, 26 Dec 2025 05:45:05 +0000 Subject: [PATCH 02/10] Use consistent paths in 7.x about_Format.ps1xml Both Update-FormatData examples now use the $HOME\Format example path. This also updates the first example to create the directory before calling Export-FormatData, as the directory doesn't exist by default and Export-FormatData fails if part of the path is missing. --- .../About/about_Format.ps1xml.md | 10 ++++++---- .../About/about_Format.ps1xml.md | 10 ++++++---- .../About/about_Format.ps1xml.md | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 64ca92f95698..9adf9aeb0d44 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -1,7 +1,7 @@ --- description: Beginning in PowerShell 6, the default views for objects are defined in PowerShell source code. 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. Locale: en-US -ms.date: 04/25/2022 +ms.date: 12/26/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_format.ps1xml?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_Format.ps1xml @@ -93,8 +93,10 @@ To begin, get the format data from the source code file and create a `Format.ps1xml` file that contains the current view of the culture objects. ```powershell +[void] (New-Item -Path $HOME\Format -ItemType Directory) + Get-FormatData -TypeName System.Globalization.CultureInfo | - Export-FormatData -Path $HOME\Format\CultureInfo.Format.ps1xml + Export-FormatData -LiteralPath $HOME\Format\CultureInfo.Format.ps1xml ``` Open the `CultureInfo.Format.ps1xml` file in any XML or text editor, such as @@ -349,8 +351,8 @@ specific PowerShell version. ```powershell Get-FormatData -PowerShellVersion 5.1 -TypeName System.IO.DirectoryInfo | - Export-FormatData -Path ./MyGciView.Format.ps1xml -Update-FormatData -AppendPath ./MyGciView.Format.ps1xml + Export-FormatData -LiteralPath $HOME\Format\MyGciView.Format.ps1xml +Update-FormatData -AppendPath $HOME\Format\MyGciView.Format.ps1xml ``` ```xml diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index d74b9d8de1c1..9c85398521d0 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -1,7 +1,7 @@ --- description: Beginning in PowerShell 6, the default views for objects are defined in PowerShell source code. 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. Locale: en-US -ms.date: 04/25/2022 +ms.date: 12/26/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_format.ps1xml?view=powershell-7.5&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_Format.ps1xml @@ -93,8 +93,10 @@ To begin, get the format data from the source code file and create a `Format.ps1xml` file that contains the current view of the culture objects. ```powershell +[void] (New-Item -Path $HOME\Format -ItemType Directory) + Get-FormatData -TypeName System.Globalization.CultureInfo | - Export-FormatData -Path $HOME\Format\CultureInfo.Format.ps1xml + Export-FormatData -LiteralPath $HOME\Format\CultureInfo.Format.ps1xml ``` Open the `CultureInfo.Format.ps1xml` file in any XML or text editor, such as @@ -349,8 +351,8 @@ specific PowerShell version. ```powershell Get-FormatData -PowerShellVersion 5.1 -TypeName System.IO.DirectoryInfo | - Export-FormatData -Path ./MyGciView.Format.ps1xml -Update-FormatData -AppendPath ./MyGciView.Format.ps1xml + Export-FormatData -Path $HOME\Format\MyGciView.Format.ps1xml +Update-FormatData -AppendPath $HOME\Format\MyGciView.Format.ps1xml ``` ```xml diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 6d6db494c8f3..5fd8d726e2f7 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -1,7 +1,7 @@ --- description: Beginning in PowerShell 6, the default views for objects are defined in PowerShell source code. 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. Locale: en-US -ms.date: 04/25/2022 +ms.date: 12/26/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_format.ps1xml?view=powershell-7.6&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_Format.ps1xml @@ -93,8 +93,10 @@ To begin, get the format data from the source code file and create a `Format.ps1xml` file that contains the current view of the culture objects. ```powershell +[void] (New-Item -Path $HOME\Format -ItemType Directory) + Get-FormatData -TypeName System.Globalization.CultureInfo | - Export-FormatData -Path $HOME\Format\CultureInfo.Format.ps1xml + Export-FormatData -LiteralPath $HOME\Format\CultureInfo.Format.ps1xml ``` Open the `CultureInfo.Format.ps1xml` file in any XML or text editor, such as @@ -349,8 +351,8 @@ specific PowerShell version. ```powershell Get-FormatData -PowerShellVersion 5.1 -TypeName System.IO.DirectoryInfo | - Export-FormatData -Path ./MyGciView.Format.ps1xml -Update-FormatData -AppendPath ./MyGciView.Format.ps1xml + Export-FormatData -Path $HOME\Format\MyGciView.Format.ps1xml +Update-FormatData -AppendPath $HOME\Format\MyGciView.Format.ps1xml ``` ```xml From abed409e932318cc0126467883959122bc5a104b Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Fri, 26 Dec 2025 05:46:16 +0000 Subject: [PATCH 03/10] Minor style changes --- .../About/about_Format.ps1xml.md | 30 +++++++++---------- .../About/about_Format.ps1xml.md | 4 +-- .../About/about_Format.ps1xml.md | 4 +-- .../About/about_Format.ps1xml.md | 4 +-- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 2fa183012947..b28a36d3551d 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -88,7 +88,7 @@ headers, and the properties that are displayed in the body of the view. The format in `Format.ps1xml` files is applied just before the data is presented to the user. -## CREATING NEW FORMAT.PS1XML FILES +## Creating new Format.ps1xml files The `.ps1xml` files that are installed with PowerShell are digitally signed to prevent tampering because the formatting can include script blocks. To change @@ -292,7 +292,7 @@ the current PowerShell session. This example uses the **PrependPath** parameter to place the new file in a higher precedence order than the original file. For more information, see -[Update-FormatData](xref:Microsoft.PowerShell.Utility.Update-FormatData). +[Update-FormatData][03]. ```powershell Update-FormatData -PrependPath .\MyDotNetTypes.Format.ps1xml @@ -313,8 +313,8 @@ LCID Name Calendar DisplayName ## The XML in Format.ps1xml files -The full schema definition can be found in [Format.xsd](https://github.com/PowerShell/PowerShell/blob/master/src/Schemas/Format.xsd) -in the PowerShell source code repository on GitHub. +The full schema definition can be found in [Format.xsd][04] in the PowerShell +source code repository on GitHub. The **ViewDefinitions** section of each `Format.ps1xml` file contains the `` tags that define each view. A typical `` tag includes the @@ -379,13 +379,13 @@ that the `` tag is intended to display. ### WideControl tag The `` tag typically contains a `` tag. The -`` tag contains one or more `` tags. A `` tag -contains one `` tag. +`` tag contains one or more `` tags. A `` +tag contains one `` tag. A `` tag must include either a `` tag or a -`` tag. A `` tag specifies the property to display at -the specified location in the view. A `` tag specifies a script to -evaluate and display at the specified location in the view. +`` tag. A `` tag specifies the property to display +at the specified location in the view. A `` tag specifies a script +to evaluate and display at the specified location in the view. A `` tag can contain a `` tag that specifies how to display the property. @@ -399,7 +399,7 @@ multiple `` tags. Each `` tag contains a formatting of the specified location in the view, including ``, ``, ``, and `` tags. -## DEFAULT DISPLAYS IN TYPES.PS1XML +## Default displays in Types.ps1xml The default displays of some basic object types are defined in the `Types.ps1xml` file in the `$PSHOME` directory. The nodes are named @@ -420,15 +420,12 @@ value of the **Name** parameter: - FormatFileLoading - FormatViewBinding -For more information, see -[Trace-Command](xref:Microsoft.PowerShell.Utility.Trace-Command) and -[Get-TraceSource](xref:Microsoft.PowerShell.Utility.Get-TraceSource). +For more information, see [Trace-Command][05] and [Get-TraceSource][06]. ## Signing a Format.ps1xml file To protect the users of your `Format.ps1xml` file, sign the file using a -digital signature. For more information, see -[about_Signing](about_Signing.md). +digital signature. For more information, see [about_Signing][07]. ## Sample XML for a Format-Table custom view @@ -598,9 +595,10 @@ Update-FormatData -PrependPath .\MyFileSystem.Format.ps1xml [01]: xref:Microsoft.PowerShell.Utility.Get-FormatData [02]: xref:Microsoft.PowerShell.Utility.Export-FormatData [03]: xref:Microsoft.PowerShell.Utility.Update-FormatData - +[04]: https://github.com/PowerShell/PowerShell/blob/master/src/Schemas/Format.xsd [05]: xref:Microsoft.PowerShell.Utility.Trace-Command [06]: xref:Microsoft.PowerShell.Utility.Get-TraceSource +[07]: about_Signing.md [08]: xref:Microsoft.PowerShell.Utility.Format-Table [09]: /powershell/scripting/developer/format/format-schema-xml-reference [10]: /powershell/scripting/developer/format/writing-a-powershell-formatting-file diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 9adf9aeb0d44..3f3097a39e81 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -280,8 +280,8 @@ that the `` tag is intended to display. ### WideControl tag The `` tag typically contains a `` tag. The -`` tag contains one or more `` tags. A `` tag -contains one `` tag. +`` tag contains one or more `` tags. A `` +tag contains one `` tag. A `` tag must include either a `` tag or a `` tag. A `` tag specifies the property to display diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 9c85398521d0..11b0235102ae 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -280,8 +280,8 @@ that the `` tag is intended to display. ### WideControl tag The `` tag typically contains a `` tag. The -`` tag contains one or more `` tags. A `` tag -contains one `` tag. +`` tag contains one or more `` tags. A `` +tag contains one `` tag. A `` tag must include either a `` tag or a `` tag. A `` tag specifies the property to display diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 5fd8d726e2f7..edd3c2e0b955 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -280,8 +280,8 @@ that the `` tag is intended to display. ### WideControl tag The `` tag typically contains a `` tag. The -`` tag contains one or more `` tags. A `` tag -contains one `` tag. +`` tag contains one or more `` tags. A `` +tag contains one `` tag. A `` tag must include either a `` tag or a `` tag. A `` tag specifies the property to display From 5b37923eecf69ccd1a299be2bfe89c72baa4f722 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Fri, 26 Dec 2025 05:57:35 +0000 Subject: [PATCH 04/10] Specify the correct formatting file extension This fixes the incorrect assertion that formatting files **must** use `.format.ps1xml` (only `.ps1xml` is required). --- ...ow-to-create-a-formatting-file-format-ps1xml.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md index a41ec614682a..090c3ea06199 100644 --- a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md +++ b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md @@ -1,18 +1,18 @@ --- -description: How to Create a Formatting File (.format.ps1xml) -ms.date: 08/23/2021 -title: How to Create a Formatting File (.format.ps1xml) +description: How to Create a Formatting File (Format.ps1xml) +ms.date: 12/26/2025 +title: How to Create a Formatting File (Format.ps1xml) --- -# How to Create a Formatting File (.format.ps1xml) +# How to Create a Formatting File (Format.ps1xml) -This topic describes how to create a formatting file (.format.ps1xml). +This topic describes how to create a formatting file (`Format.ps1xml`). > [!NOTE] > You can also create a formatting file by making a copy of one of the files provided by Windows > PowerShell. If you make a copy of an existing file, delete the existing digital signature, and add > your own signature to the new file. -## Create a .format.ps1xml file. +## Create a Format.ps1xml file 1. Create a text file (.txt) using a text editor such as Notepad. @@ -34,7 +34,7 @@ This topic describes how to create a formatting file (.format.ps1xml). 1. Save the file to the Windows PowerShell installation folder, to your module folder, or to a subfolder of the module folder. Use the following name format when you save the file: - `MyFile.format.ps1xml`. Formatting files must use the `.format.ps1xml` extension. + `MyFile.Format.ps1xml`. Formatting files must use the `.ps1xml` extension. You are now ready to add views to the formatting file. There is no limit to the number of views that can be defined in a formatting file. You can add a single view for each object, multiple From dac7cb09c080e02c74d869187c0339c2e1782238 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Fri, 26 Dec 2025 06:01:51 +0000 Subject: [PATCH 05/10] Adjust formatting file signing note The original note suggests that after copying Win PS formatting files, the signature block should be replaced. However, the files don't actually contain a signature block to begin with. This may cause confusion, so the note is updated with a more generalized suggestion on signing taken from about_Format.ps1xml. Also includes minor style changes and less Windows-specific references. --- ...-create-a-formatting-file-format-ps1xml.md | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md index 090c3ea06199..651b427b9f20 100644 --- a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md +++ b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md @@ -9,17 +9,17 @@ This topic describes how to create a formatting file (`Format.ps1xml`). > [!NOTE] > You can also create a formatting file by making a copy of one of the files provided by Windows -> PowerShell. If you make a copy of an existing file, delete the existing digital signature, and add -> your own signature to the new file. - +> PowerShell. To protect the users of your `Format.ps1xml` file, sign the file using a digital +> signature. For more information, see [about_Signing][01]. ## Create a Format.ps1xml file -1. Create a text file (.txt) using a text editor such as Notepad. + +1. Open a new text file using a text editor such as Visual Studio Code. 1. Copy the following lines into the formatting file. ```xml - + @@ -32,7 +32,7 @@ This topic describes how to create a formatting file (`Format.ps1xml`). - The `` tags define the `ViewDefinitions` node. All views are defined within this node. -1. Save the file to the Windows PowerShell installation folder, to your module folder, or to a +1. Save the file to a folder of your choice. If you are writing a module, save the file to a subfolder of the module folder. Use the following name format when you save the file: `MyFile.Format.ps1xml`. Formatting files must use the `.ps1xml` extension. @@ -40,6 +40,10 @@ This topic describes how to create a formatting file (`Format.ps1xml`). that can be defined in a formatting file. You can add a single view for each object, multiple views for the same object, or a single view that is used by multiple objects. -## See Also +## See also + +- [Writing a Windows PowerShell Formatting and Types File][02] -[Writing a Windows PowerShell Formatting and Types File](./writing-a-powershell-formatting-file.md) + +[01]: /powershell/module/microsoft.powershell.core/about/about_signing.md +[02]: (./writing-a-powershell-formatting-file.md) From 6fc32e9a8d831761eefa5c111b3605c7f04d8e88 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Fri, 26 Dec 2025 06:43:41 +0000 Subject: [PATCH 06/10] Use the same example path in all doc versions The 7.x docs use `$HOME\Format` as an example directory. This updates the 5.1 doc to use the same path. It also removes the suggestion to place custom formatting files in Win PS's `$PSHOME`. As this is a system directory, it's not an appropriate location for user files. --- .../About/about_Format.ps1xml.md | 18 +++++++++--------- .../About/about_Format.ps1xml.md | 2 +- .../About/about_Format.ps1xml.md | 2 +- .../About/about_Format.ps1xml.md | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index b28a36d3551d..b2a0c85b5c3e 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -98,9 +98,7 @@ session. 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 PowerShell, but it's useful -to place the files in the PowerShell installation directory (`$PSHOME`) or in a -subdirectory of the installation directory. +the new file in any directory that is accessible to PowerShell. 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 @@ -144,13 +142,15 @@ C:\Windows\System32\WindowsPowerShell\v1.0\DotNetTypes.format.ps1xml:115: This command reveals that the definition is in the `DotNetTypes.format.ps1xml` file. -The next command copies the file contents to a new file, -`MyDotNetTypes.Format.ps1xml`. +The following commands copy the file contents to a new file named +`MyDotNetTypes.Format.ps1xml` in a newly created `$HOME\Format` directory. ```powershell +[void] (New-Item -Path $HOME\Format -ItemType Directory -Force) + $copyParams = @{ LiteralPath = "$PSHOME\DotNetTypes.format.ps1xml" - Destination = '.\MyDotNetTypes.Format.ps1xml' + Destination = "$HOME\Format\MyDotNetTypes.Format.ps1xml" } Copy-Item @copyParams ``` @@ -295,7 +295,7 @@ higher precedence order than the original file. For more information, see [Update-FormatData][03]. ```powershell -Update-FormatData -PrependPath .\MyDotNetTypes.Format.ps1xml +Update-FormatData -PrependPath $HOME\Format\MyDotNetTypes.Format.ps1xml ``` To test the change, type `Get-Culture` and review the output that includes the @@ -461,11 +461,11 @@ Select-String @selectParams $copyParams = @{ LiteralPath = "$PSHOME\FileSystem.format.ps1xml" - Destination = '.\MyFileSystem.Format.ps1xml' + Destination = "$HOME\Format\MyFileSystem.Format.ps1xml" } Copy-Item @copyParams -Update-FormatData -PrependPath .\MyFileSystem.Format.ps1xml +Update-FormatData -PrependPath $HOME\Format\MyFileSystem.Format.ps1xml ``` > [!NOTE] diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 3f3097a39e81..fdf5d1391840 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -93,7 +93,7 @@ To begin, get the format data from the source code file and create a `Format.ps1xml` file that contains the current view of the culture objects. ```powershell -[void] (New-Item -Path $HOME\Format -ItemType Directory) +[void] (New-Item -Path $HOME\Format -ItemType Directory -Force) Get-FormatData -TypeName System.Globalization.CultureInfo | Export-FormatData -LiteralPath $HOME\Format\CultureInfo.Format.ps1xml diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 11b0235102ae..ad3210f0db6f 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -93,7 +93,7 @@ To begin, get the format data from the source code file and create a `Format.ps1xml` file that contains the current view of the culture objects. ```powershell -[void] (New-Item -Path $HOME\Format -ItemType Directory) +[void] (New-Item -Path $HOME\Format -ItemType Directory -Force) Get-FormatData -TypeName System.Globalization.CultureInfo | Export-FormatData -LiteralPath $HOME\Format\CultureInfo.Format.ps1xml diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index edd3c2e0b955..15d0170f03e2 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -93,7 +93,7 @@ To begin, get the format data from the source code file and create a `Format.ps1xml` file that contains the current view of the culture objects. ```powershell -[void] (New-Item -Path $HOME\Format -ItemType Directory) +[void] (New-Item -Path $HOME\Format -ItemType Directory -Force) Get-FormatData -TypeName System.Globalization.CultureInfo | Export-FormatData -LiteralPath $HOME\Format\CultureInfo.Format.ps1xml From 19bca110068d5ca9f8756780040e7bf9d4c303e3 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Fri, 26 Dec 2025 06:54:47 +0000 Subject: [PATCH 07/10] Fix formatting --- .../format/how-to-create-a-formatting-file-format-ps1xml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md index 651b427b9f20..6c45977d3256 100644 --- a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md +++ b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md @@ -11,8 +11,8 @@ This topic describes how to create a formatting file (`Format.ps1xml`). > You can also create a formatting file by making a copy of one of the files provided by Windows > PowerShell. To protect the users of your `Format.ps1xml` file, sign the file using a digital > signature. For more information, see [about_Signing][01]. -## Create a Format.ps1xml file +## Create a Format.ps1xml file 1. Open a new text file using a text editor such as Visual Studio Code. From 1444bd369e1c520246c0635d1cd035eefc3ebd3b Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Fri, 26 Dec 2025 07:07:53 +0000 Subject: [PATCH 08/10] Fix link references --- .../format/how-to-create-a-formatting-file-format-ps1xml.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md index 6c45977d3256..6bd229336ccb 100644 --- a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md +++ b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md @@ -42,8 +42,10 @@ This topic describes how to create a formatting file (`Format.ps1xml`). ## See also -- [Writing a Windows PowerShell Formatting and Types File][02] +- [Formatting File Overview][02] +- [Formatting File Concepts][03] [01]: /powershell/module/microsoft.powershell.core/about/about_signing.md -[02]: (./writing-a-powershell-formatting-file.md) +[02]: ./formatting-file-overview.md +[03]: ./formatting-file-concepts.md From f10fb545ec7824b0592abfc74dd48955dc19f081 Mon Sep 17 00:00:00 2001 From: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> Date: Fri, 26 Dec 2025 07:19:18 +0000 Subject: [PATCH 09/10] Fix link references again --- .../format/how-to-create-a-formatting-file-format-ps1xml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md index 6bd229336ccb..4348a6f1d239 100644 --- a/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md +++ b/reference/docs-conceptual/developer/format/how-to-create-a-formatting-file-format-ps1xml.md @@ -46,6 +46,6 @@ This topic describes how to create a formatting file (`Format.ps1xml`). - [Formatting File Concepts][03] -[01]: /powershell/module/microsoft.powershell.core/about/about_signing.md +[01]: /powershell/module/microsoft.powershell.core/about/about_signing [02]: ./formatting-file-overview.md [03]: ./formatting-file-concepts.md From 5d421c489feab1199b8f486f45a7f36624adb91c Mon Sep 17 00:00:00 2001 From: "Mikey Lombardi (He/Him)" Date: Fri, 2 Jan 2026 14:44:30 -0600 Subject: [PATCH 10/10] Apply suggestions from review --- .../5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md | 2 +- .../7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md | 3 ++- .../7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md | 3 ++- .../7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index b2a0c85b5c3e..ca996409bbef 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -146,7 +146,7 @@ The following commands copy the file contents to a new file named `MyDotNetTypes.Format.ps1xml` in a newly created `$HOME\Format` directory. ```powershell -[void] (New-Item -Path $HOME\Format -ItemType Directory -Force) +New-Item -Path $HOME\Format -ItemType Directory -Force $copyParams = @{ LiteralPath = "$PSHOME\DotNetTypes.format.ps1xml" diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index fdf5d1391840..e4d49cef93ed 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -93,7 +93,7 @@ To begin, get the format data from the source code file and create a `Format.ps1xml` file that contains the current view of the culture objects. ```powershell -[void] (New-Item -Path $HOME\Format -ItemType Directory -Force) +New-Item -Path $HOME\Format -ItemType Directory -Force Get-FormatData -TypeName System.Globalization.CultureInfo | Export-FormatData -LiteralPath $HOME\Format\CultureInfo.Format.ps1xml @@ -352,6 +352,7 @@ specific PowerShell version. ```powershell Get-FormatData -PowerShellVersion 5.1 -TypeName System.IO.DirectoryInfo | Export-FormatData -LiteralPath $HOME\Format\MyGciView.Format.ps1xml + Update-FormatData -AppendPath $HOME\Format\MyGciView.Format.ps1xml ``` diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index ad3210f0db6f..ff09056394e1 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -93,7 +93,7 @@ To begin, get the format data from the source code file and create a `Format.ps1xml` file that contains the current view of the culture objects. ```powershell -[void] (New-Item -Path $HOME\Format -ItemType Directory -Force) +New-Item -Path $HOME\Format -ItemType Directory -Force Get-FormatData -TypeName System.Globalization.CultureInfo | Export-FormatData -LiteralPath $HOME\Format\CultureInfo.Format.ps1xml @@ -352,6 +352,7 @@ specific PowerShell version. ```powershell Get-FormatData -PowerShellVersion 5.1 -TypeName System.IO.DirectoryInfo | Export-FormatData -Path $HOME\Format\MyGciView.Format.ps1xml + Update-FormatData -AppendPath $HOME\Format\MyGciView.Format.ps1xml ``` diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index 15d0170f03e2..b8cefcf7a508 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -93,7 +93,7 @@ To begin, get the format data from the source code file and create a `Format.ps1xml` file that contains the current view of the culture objects. ```powershell -[void] (New-Item -Path $HOME\Format -ItemType Directory -Force) +New-Item -Path $HOME\Format -ItemType Directory -Force Get-FormatData -TypeName System.Globalization.CultureInfo | Export-FormatData -LiteralPath $HOME\Format\CultureInfo.Format.ps1xml @@ -352,6 +352,7 @@ specific PowerShell version. ```powershell Get-FormatData -PowerShellVersion 5.1 -TypeName System.IO.DirectoryInfo | Export-FormatData -Path $HOME\Format\MyGciView.Format.ps1xml + Update-FormatData -AppendPath $HOME\Format\MyGciView.Format.ps1xml ```