Skip to content

Commit

Permalink
(GH-11321) Add examples for DefaultDisplayProperty
Browse files Browse the repository at this point in the history
Prior to this change, the documentation didn't include examples
of defining the default display property in a `Types.ps1xml`
file or with the `Update-TypeData` cmdlet.

This change:

- Adds a new example to the `Update-TypeData` cmdlet showing how
  a user can define a script property and set it as the default
  display property in a single command.
- Updates existing examples for line length and readability.
- Updates the example showing **PSStandardMembers** in
  `about_Types.ps1xml` to include a default display property.
- Fixes AB#294774
- Resolves #11321
  • Loading branch information
michaeltlombardi committed Aug 7, 2024
1 parent fce5e8d commit 5025c01
Show file tree
Hide file tree
Showing 8 changed files with 904 additions and 192 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use `Types.ps1xml` files to extend the types of objects that are used in PowerShell.
Locale: en-US
ms.date: 04/30/2021
ms.date: 08/07/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_types.ps1xml?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Types.ps1xml
Expand Down Expand Up @@ -357,8 +357,9 @@ following:
For example, the following XML defines the default display of services
(`System.ServiceProcess.ServiceController` objects) that are returned by the
`Get-Service` cmdlet. It defines a member set named **PsStandardMembers** that
consists of a default property set with the **Status**, **Name**, and
**DisplayName** properties.
consists of a default property set and a default display property. It defines
the default property set as the **Status**, **Name**, and **DisplayName**
properties. It defines the default display property as **Name**.

```xml
<Type>
Expand All @@ -375,6 +376,10 @@ consists of a default property set with the **Status**, **Name**, and
<Name>DisplayName</Name>
</ReferencedProperties>
</PropertySet>
<NoteProperty>
<Name>DefaultDisplayProperty</Name>
<Value>Name</Value>
</NoteProperty>
</Members>
</MemberSet>
</Members>
Expand Down
257 changes: 212 additions & 45 deletions reference/5.1/Microsoft.PowerShell.Utility/Update-TypeData.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use `Types.ps1xml` files to extend the types of objects that are used in PowerShell.
Locale: en-US
ms.date: 04/30/2021
ms.date: 08/07/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_types.ps1xml?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Types.ps1xml
Expand Down Expand Up @@ -358,8 +358,9 @@ following:
For example, the following XML defines the default display of services
(`System.ServiceProcess.ServiceController` objects) that are returned by the
`Get-Service` cmdlet. It defines a member set named **PsStandardMembers** that
consists of a default property set with the **Status**, **Name**, and
**DisplayName** properties.
consists of a default property set and a default display property. It defines
the default property set as the **Status**, **Name**, and **DisplayName**
properties. It defines the default display property as **Name**.

```xml
<Type>
Expand All @@ -376,6 +377,10 @@ consists of a default property set with the **Status**, **Name**, and
<Name>DisplayName</Name>
</ReferencedProperties>
</PropertySet>
<NoteProperty>
<Name>DefaultDisplayProperty</Name>
<Value>Name</Value>
</NoteProperty>
</Members>
</MemberSet>
</Members>
Expand Down
265 changes: 220 additions & 45 deletions reference/7.2/Microsoft.PowerShell.Utility/Update-TypeData.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use `Types.ps1xml` files to extend the types of objects that are used in PowerShell.
Locale: en-US
ms.date: 04/30/2021
ms.date: 08/07/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_types.ps1xml?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Types.ps1xml
Expand Down Expand Up @@ -358,8 +358,9 @@ following:
For example, the following XML defines the default display of services
(`System.ServiceProcess.ServiceController` objects) that are returned by the
`Get-Service` cmdlet. It defines a member set named **PsStandardMembers** that
consists of a default property set with the **Status**, **Name**, and
**DisplayName** properties.
consists of a default property set and a default display property. It defines
the default property set as the **Status**, **Name**, and **DisplayName**
properties. It defines the default display property as **Name**.

```xml
<Type>
Expand All @@ -376,6 +377,10 @@ consists of a default property set with the **Status**, **Name**, and
<Name>DisplayName</Name>
</ReferencedProperties>
</PropertySet>
<NoteProperty>
<Name>DefaultDisplayProperty</Name>
<Value>Name</Value>
</NoteProperty>
</Members>
</MemberSet>
</Members>
Expand Down
265 changes: 220 additions & 45 deletions reference/7.4/Microsoft.PowerShell.Utility/Update-TypeData.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use `Types.ps1xml` files to extend the types of objects that are used in PowerShell.
Locale: en-US
ms.date: 04/30/2021
ms.date: 08/07/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_types.ps1xml?view=powershell-7.5&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Types.ps1xml
Expand Down Expand Up @@ -358,8 +358,9 @@ following:
For example, the following XML defines the default display of services
(`System.ServiceProcess.ServiceController` objects) that are returned by the
`Get-Service` cmdlet. It defines a member set named **PsStandardMembers** that
consists of a default property set with the **Status**, **Name**, and
**DisplayName** properties.
consists of a default property set and a default display property. It defines
the default property set as the **Status**, **Name**, and **DisplayName**
properties. It defines the default display property as **Name**.

```xml
<Type>
Expand All @@ -376,6 +377,10 @@ consists of a default property set with the **Status**, **Name**, and
<Name>DisplayName</Name>
</ReferencedProperties>
</PropertySet>
<NoteProperty>
<Name>DefaultDisplayProperty</Name>
<Value>Name</Value>
</NoteProperty>
</Members>
</MemberSet>
</Members>
Expand Down
Loading

0 comments on commit 5025c01

Please sign in to comment.