Information
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.

Wide View (GroupBy)

 

This example shows how to implement a wide view that displays groups of System.ServiceProcess.ServiceController objects returned by the Get-Service cmdlet. For more information about the components of a wide view, see Creating a Wide 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.

    System_CAPS_warningWarning

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

Demonstrates

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 when a new group is displayed.

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

Example

The following XML defines a wide view that displays groups of objects. Each new group is started when the value of the ServiceController.ServiceType property changes.

<?xml version="1.0" encoding="utf-8" ?>

<Configuration>  
  <ViewDefinitions>
    <View>
      <Name>ServiceWideView</Name>
      <ViewSelectedBy>
        <TypeName>System.ServiceProcess.ServiceController</TypeName>
      </ViewSelectedBy>
      <GroupBy>
        <Label>Service Type</Label>
        <PropertyName>ServiceType</PropertyName>
      </GroupBy>
      <WideControl>
        <WideEntries>
          <WideEntry>
            <WideItem>
              <PropertyName>ServiceName</PropertyName>
            </WideItem>
          </WideEntry>
        </WideEntries>
      </WideControl>
    </View>
  </ViewDefinitions>
</Configuration>

The following example shows how Windows PowerShell displays the System.ServiceProcess.ServiceController objects after this format file is loaded.

PS> get-service f*
   Service Type: Win32OwnProcess

Fax                             FCSAM

   Service Type: Win32ShareProcess

fdPHost                         FDResPub
FontCache

   Service Type: Win32OwnProcess

FontCache3.0.0.0                FSysAgent
FwcAgent

Show: