The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

List View (GroupBy)


This example shows how to implement a list view that separates the rows of the list into groups. This list view displays the properties of the System.ServiceProcess.ServiceController objects returned by the Get-Service cmdlet. For more information about the components of a list view, see Creating a List View.

To load this formatting file

  1. Copy the XML from the Example section of this topic into a text file.

  2. Save the text file. Be sure to add the format.ps1xml extension to the file to identify it as a formatting file.

  3. Open Windows PowerShell, and run the following command to load the formatting file into the current session: Update-formatdata –prependpath PathToFormattingFile.


    This formatting file defines the display of an object that is already defined by a Windows PowerShell formatting file. You must use the prependPath parameter when you run the cmdlet, and you cannot load this formatting file as a module.


This formatting file demonstrates the following XML elements:

  • The Name element for the view.

  • The ViewSelectedBy element that defines what objects are displayed by the view.

  • The GroupBy element that defines how a new group of objects is displayed.

  • The ListControl element that defines what property is displayed by the view.

  • The ListItem element that defines what is displayed in a row of the list view.

  • The PropertyName element that defines which property is displayed.


The following XML defines a list view that starts a new group whenever the value of the ServiceController.Status property changes. When each group is started, a custom label is displayed that includes the new value of the property.

        <Label>New Service Status</Label>

The following example shows how Windows PowerShell displays the System.ServiceProcess.ServiceController objects after this format file is loaded. The blank lines added before and after the group label are automatically added by Windows PowerShell.

PS> get-service f*
   New Service Status: Stopped

Name        : Fax
DisplayName : Fax
ServiceType : Win32OwnProcess

   New Service Status: Running

Name        : FCSAM
DisplayName : Microsoft Antimalware Service
ServiceType : Win32OwnProcess

   New Service Status: Stopped

Name        : fdPHost
DisplayName : Function Discovery Provider Host
ServiceType : Win32ShareProcess

   New Service Status: Running

Name        : FDResPub
DisplayName : Function Discovery Resource Publication
ServiceType : Win32ShareProcess

Name        : FontCache
DisplayName : Windows Font Cache Service
ServiceType : Win32ShareProcess

   New Service Status: Stopped

Name        : FontCache3.0.0.0
DisplayName : Windows Presentation Foundation Font Cache
ServiceType : Win32OwnProcess

   New Service Status: Running

Name        : FSysAgent
DisplayName : Microsoft Forefront System Agent
ServiceType : Win32OwnProcess

Name        : FwcAgent
DisplayName : Firewall Client Agent
ServiceType : Win32OwnProcess