PowerTip: Expand Objects in PowerShell

Summary: Learn how to easily expand objects in Windows PowerShell.

Hey, Scripting Guy! Question How can I expand an object that was returned by my Windows PowerShell expression?

Hey, Scripting Guy! Answer Use the –ExpandProperty parameter from Select-Object to expand objects in Windows PowerShell.
           This example expands the System.Diagnostics.ProcessStartInfo object returned by the Get-Process cmdlet:

Get-Process | Select-Object -ExpandProperty startinfo

Comments (2)

  1. Just Karl says:

    I saw Jeffrey Snover use this to shortcut this:
    Get-Process |ForEach-Object startinfo

    Technically, he did Get-Process |% startinfo

    I used to get group membership like this:
    Get-Group GroupName |Select-Object -ExpandProperty Members |Select-Object Name

    Now I do:
    Get-Group GroupName |% Members |% Name

  2. For a graphical representation of the expanded properties check out the PowerShell Object Browser

Skip to main content