Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
May 25, 2023

Getting Your Group On

I thought I’d give you a break from the weather function and Pester test. We’ll pick that series later. In the meantime, I thought I’d dive into one of my favorite PowerShell commands or at least one that I often use in my PowerShell scripting, Group-Object.

On the surface, the command seems pretty simple. Give the command a bunch of objects, which will group them on a specific property.

PS C:\> Get-Service -name m* | Group-Object -Property Status

Count Name                      Group
----- ----                      -----
   10 Stopped                   {MapsBroker, McpManagementService, Messaging… 
    3 Running                   {mpssvc, MSSQL$SQLEXPRESS, Muse Hub Backgrou…

You can use any object property that you see using Get-Member.

Want to read the full issue?
GitHub Bluesky LinkedIn About Jeff
Powered by Buttondown, the easiest way to start and grow your newsletter.