Powershell – expanding powershell cmdlet group-object

powershell

I'm having an issue using the cmdlet Group-Object. Take this for example:

PS C:\Windows> get-service | Group-Object -Property status

        Count Name      Group           
        ----- ----      -----   
        114 Running   {AdobeARMservice, Appinfo, AppMgmt...}
        128 Stopped   {AdobeFlashPlayerUpdateSvc, AJRouter...}

See how the group column doesn't show all the names but rather truncates them with an ellipsis. I know I can pipe Select-Object -expandproperty group cmdlet afterwards to get the full list but that will only output the group column and not the count and name columns. I know I can also replace group-object and just use format-table -wrap to get the list expanded with the other columns but I need the count column and that wouldn't show up without Group-Object.

Anyone know how to do this while still using Group-Object? This is not just specifically for get-service but other stuff that I use group-object with. Get-service is just a generic example that anyone can relate to. Thanks.

Best Answer

Well, like I said in my comment, what you do with the output of Group-Object is entirely situation dependent. But here is an example of how you can see all the Service Names.

Get-Service | Group-Object -Property Status |
Select-Object Count, Name, @{Name="Services";Expression={$_.Group.Name -join ','}} |
Format-Table -Wrap

Count Name    Services
----- ----    --------
  108 Running AdaptiveSleepService,AMD External Events Utility,AppIDSvc,Appinfo,Apple Mobile Device
              Service,AudioEndpointBuilder,Audiosrv,BDESVC,BFE,BITS,Bonjour Service,BrokerInfrastructure,CDPSvc,
  132 Stopped AJRouter,ALG,AppMgmt,AppReadiness,AppVClient,AppXSvc,AxInstSV,Browser,BthHFSrv,bthserv,ClipSVC,COMSysApp,
              CscService,DcpSvc,defragsvc,DeviceInstall,DevQueryBroker,diagnosticshub.standardcollector.service,DmEnrol,