# Group  on multiple machines

**URL:** <https://forums.powershell.org/t/group-on-multiple-machines/5314>\
**Category:** PowerShell Help\
**Created:** [December 4, 2015, 11:35am UTC](https://forums.powershell.org/t/group-on-multiple-machines/5314 "2015-12-04T11:35:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wei-yen-tan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/wei-yen-tan/32/91_2.png) [@wei-yen-tan](https://forums.powershell.org/u/wei-yen-tan)\
**Post date:** [December 4, 2015, 11:35am UTC](https://forums.powershell.org/t/group-on-multiple-machines/5314/1 "2015-12-04T11:35:59Z")

</div>

I am using a cmdlet like Get-Eventlog on multiple machines.

Everything works but I am not quite sure how to have theevents group by computername and then indented by service.  
I saw Don doing something like that…i thought it might be group-object but this gave me a count of all events

I did this/:

get-eventlog -ComputerName server1, server2 | select status, name, displayname, machinename | group machinename

But its trying to group all the events in a category as a pose by computername. any suggestions?

---

<div class="post-metadata">

**Author:** ![curtis-smith](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/curtis-smith/32/121_2.png) [@curtis-smith](https://forums.powershell.org/u/curtis-smith)\
**Post date:** [December 4, 2015, 4:45pm UTC](https://forums.powershell.org/t/group-on-multiple-machines/5314/2 "2015-12-04T16:45:06Z")

</div>

Which event log are you looking at? I checked the system, application and security event logs and none of them, and none of them on my systems have status, name, or displayname as valid properties.

And what do you mean by indented by service?

---

<div class="post-metadata">

**Author:** ![wei-yen-tan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/wei-yen-tan/32/91_2.png) [@wei-yen-tan](https://forums.powershell.org/u/wei-yen-tan)\
**Post date:** [December 4, 2015, 4:58pm UTC](https://forums.powershell.org/t/group-on-multiple-machines/5314/3 "2015-12-04T16:58:27Z")

</div>

It’s my bad Curtis. I was referring to get-service.

But I mean display like

Server1

* * *

Name , displayname , status,

server2

* * *

Name,displayname,status

---

<div class="post-metadata">

**Author:** ![curtis-smith](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/curtis-smith/32/121_2.png) [@curtis-smith](https://forums.powershell.org/u/curtis-smith)\
**Post date:** [December 4, 2015, 5:14pm UTC](https://forums.powershell.org/t/group-on-multiple-machines/5314/4 "2015-12-04T17:14:26Z")

</div>

You can do something like this

```
Get-Service -ComputerName localhost, remotehost | 
Select-Object MachineName, Name, DisplayName, Status |
Group-Object -Property MachineName |
ForEach-Object {
                $_.Name
                "----------------"
                $_.Group | 
                ForEach-Object {
                                "$($_.Name), $($_.DisplayName), $($_.Status)"
                               }
                ""
               }
```

**Results like:**  
Truncated lists to reduce post size.

```
localhost
----------------
AdobeActiveFileMonitor11.0, Adobe Active File Monitor V11, Stopped
AdobeARMservice, Adobe Acrobat Update Service, Running
AdobeFlashPlayerUpdateSvc, Adobe Flash Player Update Service, Stopped
AeLookupSvc, Application Experience, Running
AESTFilters, Andrea ST Filters Service, Running
ALG, Application Layer Gateway Service, Stopped
AppIDSvc, Application Identity, Stopped
Appinfo, Application Information, Running
Apple Mobile Device Service, Apple Mobile Device Service, Running

remotehost
----------------
AdobeARMservice, Adobe Acrobat Update Service, Running
AdobeFlashPlayerUpdateSvc, Adobe Flash Player Update Service, Stopped
AeLookupSvc, Application Experience, Running
ALG, Application Layer Gateway Service, Stopped
AppIDSvc, Application Identity, Stopped
Appinfo, Application Information, Running
AppMgmt, Application Management, Stopped
aspnet_state, ASP.NET State Service, Stopped
AudioEndpointBuilder, Windows Audio Endpoint Builder, Running
AudioSrv, Windows Audio, Running
```

---

<div class="post-metadata">

**Author:** ![csandfeld](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@csandfeld](https://forums.powershell.org/u/csandfeld)\
**Post date:** [December 4, 2015, 10:16pm UTC](https://forums.powershell.org/t/group-on-multiple-machines/5314/5 "2015-12-04T22:16:23Z")

</div>

If I understand correctly, I believe what you are after, is something like this:

```
Get-Service -ComputerName server1,server2 | Sort-Object -Property MachineName | Format-Table Name, DisplayName, Status -GroupBy MachineName
```

So with this I get the services from a number of computers, sort by the ‘MachineName’ property (necessary for the grouping to work), and use Format-Table to select the properties I want, and use the GroupBy method to do the grouping you asked for. The GroupBy method is available in the Format-List Cmdlet as well

This will produce output such as:

```
MachineName: server1

Name DisplayName Status
---- ----------- ------
AdobeARMservice Adobe Acrobat Update Service Running
AJRouter AllJoyn Router Service Stopped
ALG Application Layer Gateway Service Stopped
AppIDSvc Application Identity Stopped
Appinfo Application Information Running

   MachineName: server2

Name DisplayName Status
---- ----------- ------
AdobeARMservice Adobe Acrobat Update Service Running
AJRouter AllJoyn Router Service Stopped
ALG Application Layer Gateway Service Stopped
AppIDSvc Application Identity Stopped
Appinfo Application Information Running
```

---

<div class="post-metadata">

**Author:** ![wei-yen-tan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/wei-yen-tan/32/91_2.png) [@wei-yen-tan](https://forums.powershell.org/u/wei-yen-tan)\
**Post date:** [December 4, 2015, 10:47pm UTC](https://forums.powershell.org/t/group-on-multiple-machines/5314/6 "2015-12-04T22:47:12Z")

</div>

Thank you Christian, thats the result i wanted. thanks for the explaination

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:43pm UTC](https://forums.powershell.org/t/group-on-multiple-machines/5314/7 "2024-05-16T20:43:29Z")

</div>

Closed on May 16, 2024, 8:43pm UTC


