22external help file : Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33Locale : en-US
44Module Name : Microsoft.PowerShell.Utility
5- ms.date : 06/19/2024
5+ ms.date : 09/03/2025
66online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/select-object?view=powershell-7.4&WT.mc_id=ps-gethelp
77schema : 2.0.0
88aliases :
@@ -240,9 +240,9 @@ outputted objects have a specific standard format, the expanded property might n
240240
241241``` powershell
242242# Create a custom object to use for the Select-Object example.
243- $object = [pscustomobject]@{Name="CustomObject";Expand =@(1,2,3,4,5)}
243+ $object = [pscustomobject]@{Name="CustomObject";List =@(1,2,3,4,5)}
244244# Use the ExpandProperty parameter to Expand the property.
245- $object | Select-Object -ExpandProperty Expand -Property Name
245+ $object | Select-Object -ExpandProperty List -Property Name
246246```
247247
248248``` Output
@@ -256,35 +256,14 @@ $object | Select-Object -ExpandProperty Expand -Property Name
256256``` powershell
257257# The output did not contain the Name property, but it was added successfully.
258258# Use Get-Member to confirm the Name property was added and populated.
259- $object | Select-Object -ExpandProperty Expand -Property Name | Get-Member
259+ $object | Select-Object -ExpandProperty List -Property Name | Get-Member -MemberType Properties
260260```
261261
262262``` Output
263263 TypeName: System.Int32
264264
265265Name MemberType Definition
266266---- ---------- ----------
267- CompareTo Method int CompareTo(System.Object value), int CompareTo(int value), ...
268- Equals Method bool Equals(System.Object obj), bool Equals(int obj), bool IEq...
269- GetHashCode Method int GetHashCode()
270- GetType Method type GetType()
271- GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCode IConvertible.Ge...
272- ToBoolean Method bool IConvertible.ToBoolean(System.IFormatProvider provider)
273- ToByte Method byte IConvertible.ToByte(System.IFormatProvider provider)
274- ToChar Method char IConvertible.ToChar(System.IFormatProvider provider)
275- ToDateTime Method datetime IConvertible.ToDateTime(System.IFormatProvider provider)
276- ToDecimal Method decimal IConvertible.ToDecimal(System.IFormatProvider provider)
277- ToDouble Method double IConvertible.ToDouble(System.IFormatProvider provider)
278- ToInt16 Method int16 IConvertible.ToInt16(System.IFormatProvider provider)
279- ToInt32 Method int IConvertible.ToInt32(System.IFormatProvider provider)
280- ToInt64 Method long IConvertible.ToInt64(System.IFormatProvider provider)
281- ToSByte Method sbyte IConvertible.ToSByte(System.IFormatProvider provider)
282- ToSingle Method float IConvertible.ToSingle(System.IFormatProvider provider)
283- ToString Method string ToString(), string ToString(string format), string ToS...
284- ToType Method System.Object IConvertible.ToType(type conversionType, System...
285- ToUInt16 Method uint16 IConvertible.ToUInt16(System.IFormatProvider provider)
286- ToUInt32 Method uint32 IConvertible.ToUInt32(System.IFormatProvider provider)
287- ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatProvider provider)
288267Name NoteProperty string Name=CustomObject
289268```
290269
@@ -377,11 +356,11 @@ This example demonstrates the side-effect of using the **ExpandProperty** parame
377356
378357``` powershell
379358PS> $object = [pscustomobject]@{
380- name = 'USA'
381- children = [pscustomobject]@{
382- name = 'Southwest'
359+ name = 'USA'
360+ children = [pscustomobject]@{
361+ name = 'Southwest'
362+ }
383363 }
384- }
385364PS> $object
386365
387366name children
@@ -444,6 +423,30 @@ name children
444423USA @{name=Southwest}
445424```
446425
426+ ### Example 16: Use wildcards with the -ExpandProperty parameter
427+
428+ This example demonstrates using wildcards with the ** ExpandProperty** parameter. The wildcard
429+ character must resolve to a single property name. If the wildcard character resolves to more than
430+ one property name, ` Select-Object ` returns an error.
431+
432+ ``` powershell
433+ # Create a custom object.
434+ $object = [pscustomobject]@{
435+ Label = "MyObject"
436+ Names = @("John","Jane","Joe")
437+ Numbers = @(1,2,3,4,5)
438+ }
439+ # Try to expand multiple properties using a wildcard.
440+ $object | Select-Object -ExpandProperty N*
441+ Select-Object: Multiple properties cannot be expanded.
442+
443+ # Use a wildcard that resolves to a single property.
444+ $object | Select-Object -ExpandProperty Na*
445+ John
446+ Jane
447+ Joe
448+ ```
449+
447450## PARAMETERS
448451
449452### -CaseInsensitive
@@ -488,17 +491,19 @@ Accept wildcard characters: True
488491
489492Specifies a property to select, and indicates that an attempt should be made to expand that
490493property. If the input object pipeline doesn't have the property named, ` Select-Object` returns an
491- error.
494+ error. This parameter supports wildcards. However, the wildcard character must resolve to a single
495+ property name. If the wildcard character resolves to more than one property name, `Select-Object`
496+ returns an error.
497+
498+ When you use **ExpandProperty**, `Select-Object` attempts to expand the specified property for every
492499
493500- If the specified property is an array, each value of the array is included in the output.
494501- If the specified property is an object, the objects properties are expanded for every
495502 **InputObject**
496503
497- In either case, the output objects' **Type** matches the expanded property's **Type**.
498-
499- > [!NOTE]
500- > There is a side-effect when using **ExpandProperty**. The `Select-Object` adds the selected
501- > properties to the original object as **NoteProperty** members.
504+ In either case, the output objects' **Type** matches the expanded property's **Type**. There is a
505+ side-effect when using **ExpandProperty**. The `Select-Object` adds the selected properties to the
506+ original object as **NoteProperty** members.
502507
503508If the **Property** parameter is specified, `Select-Object` attempts to add each selected property
504509as a **NoteProperty** to every outputted object.
@@ -521,7 +526,7 @@ Required: False
521526Position: Named
522527Default value: None
523528Accept pipeline input: False
524- Accept wildcard characters: False
529+ Accept wildcard characters: True
525530` ` `
526531
527532# ## -First
0 commit comments