Group on multiple machines

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?

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?

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

But I mean display like

Server1


Name , displayname , status,

server2


Name,displayname,status

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

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

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