PS - Service Status Grouping

Soldato
Joined
25 Oct 2009
Posts
6,700
Location
Caerphilly
I have this script (server names and services redacted):

Code:
@{
  'xxxxxnew' = 'Capxxxxx'
  'xxxxxnew' = 'Capxxxxx'
  'xxxxxnew' = 'Capxxxxx'
  'xxxxxnew' = 'Capxxxxx'
}.GetEnumerator() | ForEach-Object {
  Get-Service -ComputerName $_.Name -Name $_.Value
} | Select Name, MachineName, Status

which works peferfectly fine. But how do I group the results say on MachineName?

I've tried
  • -groupby machinename
  • -group-object machinename
  • -group machinename
But keep getting an error. Any point me in the right direction please?
 
I have this script (server names and services redacted):

Code:
@{
  'xxxxxnew' = 'Capxxxxx'
  'xxxxxnew' = 'Capxxxxx'
  'xxxxxnew' = 'Capxxxxx'
  'xxxxxnew' = 'Capxxxxx'
}.GetEnumerator() | ForEach-Object {
  Get-Service -ComputerName $_.Name -Name $_.Value
} | Select Name, MachineName, Status

which works peferfectly fine. But how do I group the results say on MachineName?

I've tried
  • -groupby machinename
  • -group-object machinename
  • -group machinename
But keep getting an error. Any point me in the right direction please?

Pipe it into an sort-object so:
Code:
@{
  'xxxxxnew' = 'Capxxxxx'
  'xxxxxnew' = 'Capxxxxx'
  'xxxxxnew' = 'Capxxxxx'
  'xxxxxnew' = 'Capxxxxx'
}.GetEnumerator() | ForEach-Object {
  Get-Service -ComputerName $_.Name -Name $_.Value
} | Select Name, MachineName, Status | Sort-Object MachineName
 
Back
Top Bottom