寬型檢視 (GroupBy)
此範例示範如何執行會顯示 System.serviceprocess.dll Servicecontroller 群組的廣泛視圖 ?Displayproperty = Cmdlet 所傳回的 Fullname 物件 Get-Service
。 如需有關廣泛視圖元件的詳細資訊,請參閱 建立廣泛的視圖。
載入此格式設定檔案
將本主題的範例一節中的 XML 複製到文字檔。
儲存文字檔案。 請務必將副檔名新增
format.ps1xml
至檔案,以將它識別為格式化檔案。開啟 Windows PowerShell,然後執行下列命令,將格式化檔案載入目前的會話:
Update-FormatData -PrependPath <Path to file>
。警告
這個格式化檔案會定義已由 Windows PowerShell 格式檔案定義之物件的顯示。 當您執行 Cmdlet 時,您必須使用 PrependPath 參數,而且無法將此格式化檔案載入為模組。
示範
此格式化檔案示範下列 XML 元素:
視圖的 名稱 元素。
ViewSelectedBy元素,定義視圖要顯示的物件。
在顯示新群組時定義的 GroupBy 元素。
之 wideitem元素,定義視圖顯示的屬性。
範例
下列 XML 定義了顯示物件群組的廣泛視圖。 當 system.serviceprocess.dll. Servicecontroller 屬性的值變更時,就會啟動每個新群組。
<?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>
下列範例顯示 Windows PowerShell 如何顯示system.serviceprocess.dll. Servicecontroller?在載入此格式檔案之後,Displayproperty = Fullname 物件。
Get-Service f*
Service Type: Win32OwnProcess
Fax FCSAM
Service Type: Win32ShareProcess
fdPHost FDResPub
FontCache
Service Type: Win32OwnProcess
FontCache3.0.0.0 FSysAgent
FwcAgent
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應