---
title: "Group Objects in PowerShell: Organize Your Data"
description: "Master the PowerShell Group-Object cmdlet to group objects based on common properties and simplify data management."
canonical: "https://adamtheautomator.com/powershell-group-object/"
---

# Group Objects in PowerShell: Organize Your Data

> Master the PowerShell Group-Object cmdlet to group objects based on common properties and simplify data management.

Source: https://adamtheautomator.com/powershell-group-object/

---

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/)

![Group Objects in PowerShell: Organize Your Data](https://adamtheautomator.com/wp-content/uploads/2019/07/thailand-453393_1280.jpg)

# Group Objects in PowerShell: Organize Your Data

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)24 July 20193 min. read

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

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

Table of Contents

*   [Group-Object with no Parameters](#group-object-with-no-parameters)
*   [Grouping objects by a single property](#grouping-objects-by-a-single-property)
*   [Filtering Group-Object Output](#filtering-group-object-output)
*   [Grouping objects by multiple properties](#grouping-objects-by-multiple-properties)
*   [Summary](#summary)

When working with [PowerShell](https://adamtheautomator.com/tag/powershell/), there are times when you need to work with sets of data. We work with lots of files, user accounts, virtual machines, and more. When you display these various objects in the console, the objects will scroll down the screen one after the other with no regard for how you’d like to see them. But that’s fixable! Using the PowerShell `Group-Object` cmdlet, you can group objects together. This cmdlet acts like the [SQL GROUP BY statement](https://www.w3schools.com/sql/sql_groupby.asp).

PowerShell has a way of summarizing objects by their properties through the Powershell Group Object cmdlet. This cmdlet allows the scripter to get a bird’s eye view of lots of object properties at once in groups.

Let’s generate a bunch of objects of the same type. These objects can be of any type. However, for this demonstration, I’ll use _System.ServiceProcess.ServiceController_ objects that the `Get-Service` cmdlet returns.

> _For Group-Object to work as expected, ensure that you’re only grouping objects of the same type. It’s important that all objects have the same properties._

```powershell
PS51> $services = Get-Service
PS51> $services

Status   Name               DisplayName
------   ----               -----------
Stopped  AdtAgent           Microsoft Monitoring Agent Audit Fo...
Stopped  AJRouter           AllJoyn Router Service
Stopped  ALG                Application Layer Gateway Service
--snip--
```

> Manage and Report Active Directory, Exchange and Microsoft 365 with ManageEngine ADManager Plus. [Download Free Trial!](https://www.manageengine.com/products/ad-manager/tp/windows-active-directory-management-tool.html?utm_source=ata&utm_medium=website-listing&utm_campaign=admp-gpo)

## Group-Object with no Parameters

`Get-Service` returns all services on my local machine. Since there are a lot of services here, I can’t get an idea of their status, startup type and more. I’d like to group these services first by their status. To group these services, I’ll pipe all service objects to PowerShell’s `Group-Object` cmdlet and use the `Status` property.

```powershell
PS51> $services | Group-Object

Count Name                      Group
----- ----                      -----
  272 AdtAgent                  {AdtAgent, AJRouter, ALG, AppHostSvc...}
```

Notice that by piping all services to `Powershell Group Object`, you can get the count. Big deal but useful.

## Grouping objects by a single property

To group them by a specific property (status in this case) I need to tell `Group-Object` that I want to group on a particular object property. That’s done by using the `Property` parameter on `Group-Object`.

```powershell
PS51> $services | Group-Object -Property Status

Count Name                      Grou
----- ----                      -----
  160 Stopped                   {AdtAgent, AJRouter, ALG, AppIDSvc...}
  112 Running                   {AppHostSvc, Appinfo, Appveyor.Server, AudioEndpointBuilder...}
```

Now we’re talking! I can now see how many services are stopped and running at once. I can do the same for `StartType` as well.

```powershell
PS51> $services | Group-Object -Property StartType

Count Name                      Group
----- ----                      -----
    9 Disabled                  {AdtAgent, AppVClient, NetTcpPortSharing, RemoteAccess...}
  184 Manual                    {AJRouter, ALG, AppIDSvc, Appinfo...}
   79 Automatic                 {AppHostSvc, Appveyor.Server, AudioEndpointBuilder, Audiosrv...}
```

## Filtering Group-Object Output

Maybe I want to dive in and see the actual services in one or more of these groups. I can get these objects by looking at the `Group` property that’s returned by the Powershell group object command. The `Group` object contains all of the services that have the grouped by object property value. To get all of the stopped services if I’m grouping on service status, I can filter the services out by the status of `Stopped` and then expand the `Group` object to see all of those services.

```powershell
PS51> $services | Group-Object -Property Status | Where {$_.Name -eq 'Stopped'} | Select -ExpandProperty Group

Status   Name               DisplayName
------   ----               -----------
Stopped  AdtAgent           Microsoft Monitoring Agent Audit Fo...
Stopped  AJRouter           AllJoyn Router Service
Stopped  ALG                Application Layer Gateway Service
Stopped  AppIDSvc           Application Identity
Stopped  AppMgmt            Application Management
Stopped  AppReadiness       App Readiness
--snip--
```

## Grouping objects by multiple properties

Not only can you group objects like this on a single property, but you can also group on multiple properties as well. Perhaps you’d like to see all of the services based on their status _and_ their start type. To do so, I just need to add another property name to the `Property` parameter on `Group-Object`.

```powershell
PS51> $services | Group-Object -Property Status,StartType

Count Name                      Group
----- ----                      -----
    9 Stopped, Disabled         {AdtAgent, AppVClient, NetTcpPortSharing, RemoteAccess...}
  145 Stopped, Manual           {AJRouter, ALG, AppIDSvc, AppMgmt...}
   73 Running, Automatic        {AppHostSvc, Appveyor.Server, AudioEndpointBuilder, Audiosrv...}
   39 Running, Manual           {Appinfo, camsvc, CertPropSvc, ClipSVC...}
    6 Stopped, Automatic        {gpsvc, MapsBroker, sppsvc, TrustedInstaller...}
```

You can see by adding an additional property; you can essentially create a bunch of “and” scenarios and group on as many properties as necessary!

> Manage and Report Active Directory, Exchange and Microsoft 365 with ManageEngine ADManager Plus. [Download Free Trial!](https://www.manageengine.com/products/ad-manager/tp/windows-active-directory-management-tool.html?utm_source=ata&utm_medium=website-listing&utm_campaign=admp-gpo)

## Summary

The `Group-Object` cmdlet is a cmdlet that helps you group like objects together based on a common property. Grouping objects like this comes in handy in many different ways. I hope by learning a little about how the `Group-Object` cmdlet works, you’ll get more ideas on how to improve and create better PowerShell scripts!

If you’re just getting started with PowerShell, I highly encourage you to check out my mini-course on PowerShell tool-building!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-group-object%2F&text=Group%20Objects%20in%20PowerShell%3A%20Organize%20Your%20Data)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-group-object%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-group-object%2F)

## Related Posts

![](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.

![](https://adamtheautomator.com/wp-content/uploads/2025/06/featured-image-6.png)

### [How to Add Timeouts to Pester Tests with PowerShell Runspaces](/pester-test-timeout-runspaces/)

Prevent Pester tests from hanging indefinitely using PowerShell runspaces. Learn to handle variable scoping, module loading, TestDrive access, and stream capture challenges with timeout protection.

## 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/)
