擷取原始和格式化效能數據物件的文件
下列主題描述如何擷取動態建立的原始或格式化數據對象的在線程序設計檔。
WMI 包含一些追蹤效能的物件。 衍生自 Win32_PerfRawData 的類別包含未經處理的或「未編碼」的效能數據,且由 性能計數器提供者支援。 相反地,衍生自 Win32_PerfFormattedData 的類別包含「已煮熟」或格式化的數據,且由 格式化效能數據提供者支援。
不過,這兩個提供者都支援一些動態建立的子類別。 由於屬性會在運行時間新增,因此這些類別可能包含未記載的屬性。 您可以使用下列程式代碼來識別指定動態建立類別具有的屬性。
擷取動態建立類別的描述
建立項目的實例,並將修訂的限定符設定為 true。
$osClass = New-Object System.Management.ManagementClass Win32_ClassNameHere $osClass.Options.UseAmendedQualifiers = $true
擷取 類別的屬性。
$properties = $osClass.Properties "This class has {0} properties as follows:" -f $properties.count
顯示屬性。
foreach ($property in $properties) { "Property Name: {0}" -f $property.Name "Description: {0}" -f $($property.Qualifiers["Description"].Value) "Type: {0}" -f $property.Type "-------" }
下列程式代碼會擷取指定之 Win32_PerfFormattedData 對象的屬性描述。
$osClass = New-Object System.Management.ManagementClass Win32_PerfFormattedData_APPPOOLCountersProvider_APPPOOLWAS
$osClass.Options.UseAmendedQualifiers = $true
# Get the Properties in the class
$properties = $osClass.Properties
"This class has {0} properties as follows:" -f $properties.count
# display the Property name, description, type, qualifiers and instance values
foreach ($property in $properties) {
"Property Name: {0}" -f $property.Name
"Description: {0}" -f $($property.Qualifiers["Description"].Value)
"Type: {0}" -f $property.Type
"-------"
}