寬檢視 (基本)
此範例示範如何實作基本寬檢視,以顯示 Get-Service
Cmdlet 所傳回 System.ServiceProcess.ServiceController。 如需寬檢視元件的詳細資訊,請參閱 建立寬檢視。
載入此格式檔案
將本主題的範例區段的 XML 複製到文字檔中。
儲存文字檔。 請務必將
format.ps1xml
擴展名新增至檔案,以將其識別為格式化檔案。開啟 Windows PowerShell,然後執行下列命令,將格式化檔案載入目前的工作階段:
Update-FormatData -PrependPath <PathToFormattingFile>
。警告
此格式化檔案會定義 Windows PowerShell 格式化檔案已定義的物件顯示。 當您執行 Cmdlet 時,必須使用 PrependPath 參數,而且無法將此格式化檔案載入為模組。
演示
此格式化檔案示範下列 XML 元素:
檢視 Name 專案。
ViewSelectedBy 元素,定義檢視所顯示的物件。
WideItem 元素,定義檢視所顯示的屬性。
範例
下列 XML 會定義寬檢視,以顯示 System.ServiceProcess.ServiceController.ServiceName 属性的值。
<?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>
下列範例示範 Windows PowerShell 如何顯示載入此格式檔案之後 System.ServiceProcess.ServiceController 物件。
Get-Service f*
Fax FCSAM
fdPHost FDResPub
FontCache FontCache3.0.0.0
FSysAgent FwcAgent
另請參閱
格式化檔案 範例