編集

次の方法で共有


Wide View (Basic)

This example shows how to implement a basic wide view that displays the System.Serviceprocess.Servicecontroller?Displayproperty=Fullname objects returned by the Get-Service cmdlet. For more information about the components of a wide view, see Creating a Wide View.

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

    Warning

    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.

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 WideItem element that defines what property is displayed by the view.

Example

The following XML defines a wide view that displays the value of the System.Serviceprocess.Servicecontroller.Servicename property.

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

<Configuration>
  <ViewDefinitions>
    <View>
      <Name>ServiceWideView</Name>
      <ViewSelectedBy>
        <TypeName>System.ServiceProcess.ServiceController</TypeName>
      </ViewSelectedBy>
      <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?Displayproperty=Fullname objects after this format file is loaded.

Get-Service f*
Fax                      FCSAM
fdPHost                  FDResPub
FontCache                FontCache3.0.0.0
FSysAgent                FwcAgent

See Also

Examples of Formatting Files

Writing a PowerShell Formatting File