---
title: "How To Use the PowerShell Expand Property for Select-Object"
description: "Discover the ins-and-outs of the PowerShell expand property for the Select-Object command in this example driven tutorial!"
canonical: "https://adamtheautomator.com/powershell-expand-property/"
---

# How To Use the PowerShell Expand Property for Select-Object

> Discover the ins-and-outs of the PowerShell expand property for the Select-Object command in this example driven tutorial!

Source: https://adamtheautomator.com/powershell-expand-property/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![How To Use the PowerShell Expand Property for Select-Object](https://adamtheautomator.com/wp-content/uploads/2022/07/How-To-Use-the-PowerShell-Expand-Property-for-Select-Object.jpg)

# How To Use the PowerShell Expand Property for Select-Object

[![](https://secure.gravatar.com/avatar/b4cd4a109fc359fca6ccc8a192dd75bf9a440677bb2a87da8c23f48d76b3bb39?s=192&d=mm&r=g)Edem Afenyo](https://adamtheautomator.com/author/edem-afenyo/)10 August 20225 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[PowerShell](/tag/powershell/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Extracting Property Object Values with PowerShell Expand Property](#extracting-property-object-values-with-powershell-expand-property)
*   [Creating a Set of Selected Objects with Specific Properties](#creating-a-set-of-selected-objects-with-specific-properties)
*   [Expanding a Collection Property with PowerShell Expand Property](#expanding-a-collection-property-with-powershell-expand-property)
*   [Combining Property with PowerShell Expand Property for Categorized Output](#combining-property-with-powershell-expand-property-for-categorized-output)
*   [Combining Format-List with PowerShell Expand Property for Verbosity](#combining-format-list-with-powershell-expand-property-for-verbosity)
*   [Conclusion](#conclusion)

The PowerShell Select-Object cmdlet enables you to seamlessly cherry-pick objects and properties from an input group of objects. But sometimes you just have to know more. The [ExpandProperty](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-object?view=powershell-7.2) is a switch for Select-Object that expands details about a particular property.

Discover the power of the PowerShell Expand Property (`-ExpandProperty`) switch in this example-led tutorial.

## Prerequisites

This tutorial will be a hands-on demonstration. If you’d like to follow along, all you need is a Windows Machine with PowerShell 5.1 and above. This article uses a Windows 10 machine with PowerShell 5.1.

Related:[How to Walk Through a PowerShell 7 Upgrade](https://adamtheautomator.com/powershell-7-upgrade/)

## Extracting Property Object Values with PowerShell Expand Property

Log in to your Windows machine and fire up a PowerShell terminal. In this section, you will get acquainted with the `Select-Object` cmdlet and its `ExpandProperty` switch.

1\. Run the Get-Service cmdlet to get a list of all services on your system. Pipe the output to the Select-Object cmdlet to select and display only the name property of each service object, as shown below.

```powershell
Get-Service | Select-Object -Property Name
```

You should now see a single column of objects representing a list of names of services on your system, as in the truncated shot below.

![Selecting the names of the existing system services](https://adamtheautomator.com/wp-content/uploads/2022/07/image-552.png)

Selecting the names of the existing system services

2\. Run the Get-Member cmdlet at the tail end of the previous [pipeline](https://adamtheautomator.com/ppowershell-pipeline/) to confirm the type of objects that select-object returns as below. Knowing the type of object helps write functions or cmdlets to extend your pipelines.

```powershell
Get-Service | Select-Object -Property Name | Get-Member
```

Related:[Getting to Know the PowerShell Pipeline and Creating Functions](https://adamtheautomator.com/ppowershell-pipeline/)

Refer to the screenshot below, and you will notice that though the -Property switch outputs what appears to be a list of strings, those are the Selected list of [System.ServiceProcess.ServiceController](https://docs.microsoft.com/en-us/dotnet/api/system.serviceprocess.servicecontroller?view=dotnet-plat-ext-6.0?view=dotnet-plat-ext-6.0?view=dotnet-plat-ext-6.0) objects.

![Viewing the type of a ServiceController object with Get-Member](https://adamtheautomator.com/wp-content/uploads/2022/07/image-553.png)

Viewing the type of a ServiceController object with Get-Member

3\. Replace the Get-Members cmdlet with mkdir to automatically create a folder for each service. The -first 5 switch limits the number of objects to return. In turn, the mkdir function will only create five folders based on the objects in the pipeline.

```powershell
Get-Service | Select-Object -Property Name -First 5 | mkdir
```

You should see an output similar to the screenshot below, indicating the successful attempt.

![Creating a folder for the services on your system](https://adamtheautomator.com/wp-content/uploads/2022/07/image-554.png)

Creating a folder for the services on your system

4\. Remove the folders by replacing mkdir with rmdir as in the snippet below. Turn on the -Verbose switch to show verbose output in your terminal.

```powershell
Get-Service | Select-Object -Property Name -First 5 | rmdir -Verbose
```

The rmdir cmdlet expects strings and cannot handle the [hashtable](https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-hashtable?view=powershell-7.2) representation of the ServiceController objects. Your attempt should fail with several errors, as in the screenshot below.

![Demonstrating that some cmdlets expect string values instead of hashtables](https://adamtheautomator.com/wp-content/uploads/2022/07/image-555.png)

Demonstrating that some cmdlets expect string values instead of hashtables

Related:[Discover PowerShell to Delete Files with Remove-Item and WMI](https://adamtheautomator.com/powershell-to-delete-files/)

5\. Change the -Property switch to the -ExpandProperty switch as in the following snippet. Doing so allows you to get the value of a property as a string when all you need is a string.

```powershell
Get-Service | Select-Object -ExpandProperty Name -First 5 | rmdir -Verbose
```

Combined with rmdir, you should see your attempt to automatically remove the folders succeed without errors, as in the screenshot below.

![Deleting folders named after the services expanded](https://adamtheautomator.com/wp-content/uploads/2022/07/image-556.png)

Deleting folders named after the services expanded

## Creating a Set of Selected Objects with Specific Properties

To shorten the code snippets in the sections, create a variable for the first 20 services on your machine as follows.

Run the `Get-Service` command, select the first `20` objects via the `Select-Object` cmdlet, and store the objects in a variable named `$testServices`. Select only the `Name`, `Status`, and `DependentServices` properties as follows.

```powershell
$testServices = Get-Service | Select-Object -Property Name,Status,DependentServices -First 20
```

> _The PowerShell Expand Property switch can only expand one property at a time, in contrast to the Property switch, which can select more than one property simultaneously._

Execute the variable name, `$testServices`, to view the structure of its contents.

```powershell
$testServices
```

You should see a table displaying the properties of the services you shortlisted, similar to the screenshot below.

![Displaying the contents of $testServices](https://adamtheautomator.com/wp-content/uploads/2022/07/image-557.png)

Displaying the contents of $testServices

## Expanding a Collection Property with PowerShell Expand Property

A PowerShell object can have properties that are collections of objects, also known as collection properties. In this section, you will learn how to use PowerShell Expand Property to expand a collection property to view its members’ properties.

Execute the `Select-Object` cmdlet on the `$testServices` variable and expand the `DependentServices` property of each service.

```powershell
$testServices | Select-Object -ExpandProperty DependentServices
```

Since `DependentServices` is a collection property, the output is a list of the services in all populated collections, as shown below. Note the duplicates in the list due to concatenating results from the expanded `DependentServices`.

![Expanding the DependentServices property](https://adamtheautomator.com/wp-content/uploads/2022/07/image-558.png)

Expanding the DependentServices property

## Combining Property with PowerShell Expand Property for Categorized Output

Now you have a list of dependent services, but how do you know which service they depend on? In this section, you will learn to use the `-Property` switch to categorize an expanded property.

Run the command below to categorize the `DependentServices` properties by `Name`.

```powershell
$testServices | Select-Object -ExpandProperty DependentServices -Property Name
```

Since the dependent services already have a `Name` property, the categorization step fails, as shown below.

> _The error below tells you that the initial list of services (in $testServices) already has a Name property conflicting with a Name property in the expanded DependentServices property._

![Attempting to group an expanded property by the parent object name](https://adamtheautomator.com/wp-content/uploads/2022/07/image-559.png)

Attempting to group an expanded property by the parent object name

One workaround is to create [Calculated Properties](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_calculated_properties?view=powershell-7.2) to rename the identifier property as follows.

Save the previous command output modified to specify a calculated property called Depends On as the identifier property in a variable called $depServ. Depends on will contain the Name value for every service in $testService.

The property name, `Depends on`, was arbitrarily chosen in this tutorial and can be any expression of your choice.

```powershell
$depServ = $testServices | Select-Object -ExpandProperty DependentServices -Property @{name="Depends On"; expr={$_.Name}}
```

Pass the object in `$depServ` through `Select-Object` to select dependent service `Name`, `Status`, and `Depends On` properties.

```powershell
$depServ | Select-Object -Property Name,Status,"Depends On"
```

You can now tell which services depend on the services in `$testServices`, as shown below.

![Grouping an expanded property using a calculated property](https://adamtheautomator.com/wp-content/uploads/2022/07/image-560.png)

Grouping an expanded property using a calculated property

## Combining Format-List with PowerShell Expand Property for Verbosity

PowerShell may limit which object properties to display, especially in tabular output, and the `-ExpandProperty` switch output may experience the same. You could show the expanded properties in a list instead as a workaround.

Run the `Get-Process` cmdlet below to retrieve all the `modules` the `explorer` process uses. Turn on the `-ExpandProperty` switch to display the properties of the modules.

```powershell
Get-Process explorer | select-object -ExpandProperty Modules
```

The output on your screen should resemble the following screenshot, automatically truncated to display only three properties.

![Viewing the truncated output of an expanded property](https://adamtheautomator.com/wp-content/uploads/2022/07/image-561.png)

Viewing the truncated output of an expanded property

Pipe the objects to the `Format-List` cmdlet to view all the values for the module objects in a more manageable list.

```powershell
Get-Process explorer | select-object -ExpandProperty Modules | Format-List
```

As shown below, the output lists all properties and their values. You can further save the data to a file or pass it to another cmdlet for further processing.

![Converting the output of an expanded property to a list with Format-List](https://adamtheautomator.com/wp-content/uploads/2022/07/image-562.png)

Converting the output of an expanded property to a list with Format-List

## Conclusion

By successfully getting this far, you have seen how to benefit from the PowerShell Expand Property switch (-ExpandProperty) of the Select-Object cmdlet. PowerShell packs a host of useful cmdlets for many common tasks. You can augment your new knowledge by learning how to display files with PowerShell Cat quickly.

Related:[How to Quickly Display Files With PowerShell Cat](https://adamtheautomator.com/powershell-cat/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-expand-property%2F&text=How%20To%20Use%20the%20PowerShell%20Expand%20Property%20for%20Select-Object)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-expand-property%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-expand-property%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/publisher/2e05d9c85b2b81feb24af1f04a889143/3eab14af9dabf46fbd333914ce6ccf46f84117d2394d3e7218c186cd249bb7e2.webp)

### [PowerShell or Power Automate: Stop Automation Mistakes](/powershell-vs-power-automate/)

Score six factors to choose between PowerShell and Power Automate: target system, complexity, data volume, team skills, cost, governance.

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
