([xml](get-WMIObject win32_operatingsystem).GetText("WmiDtd20")).save("c:\os.xml")
# get methodinfo
MSH>(get-WMIObject win32_operatingsystem).GetText
MemberType : Method
OverloadDefinitions : {System.String GetText(TextFormat format)}
TypeOfValue : System.Management.Automation.MshMethod
Value : System.String GetText(TextFormat format)
Name : GetText
IsInstance : True
# get the full Classname
MSH>(get-WMIObject win32_operatingsystem).GetText("foo")
Cannot convert argument "0", with value: "lol", for "GetText" to type "System.Management.TextFormat".
At line:1 char:46
# get the formats
[enum]::getnames([System.Management.TextFormat])
Mof
CimDtd20
WmiDtd20
# get te MOF text
(get-WMIObject win32_operatingsystem).GetText("Mof")
# get the XML text.
MSH>(get-WMIObject win32_operatingsystem).GetText("WmiDtd20")
<INSTANCE CLASSNAME="Win32_OperatingSystem"><QUALIFIER NAME="dynamic" PROPAGATED="true" TYPE="boolean" TOSUBCLASS="false" TOINSTANCE="true"
><VALUE>TRUE</VALUE></QUALIFIER><QUALIFIER NAME="Locale" PROPAGATED="true" TYPE="sint32" TOSUBCLASS="false" TOINSTANCE="true"><VALUE>1033</
...
....
# get the instance to an XML document
[xml]$os = (get-WMIObject win32_operatingsystem).GetText("WmiDtd20")
MSH>$os
INSTANCE
--------
INSTANCE
MSH>$os.INSTANCE
CLASSNAME QUALIFIER PROPERTY PROPERTY.ARRAY
--------- --------- -------- --------------
Win32_OperatingSystem {dynamic, Locale, provider, UUID} {__PATH, __NAMESPACE, __SERVER,... PROPERTY.ARRAY
MSH>$os.INSTANCE.property
NAME CLASSORIGIN TYPE VALUE
---- ----------- ---- -----
__PATH ___SYSTEM string \\puter\root\cimv2:Win32_O...
__NAMESPACE ___SYSTEM string root\cimv2
...
...
# a single property
MSH>$os.INSTANCE.property[10]
NAME : BuildNumber
CLASSORIGIN : Win32_OperatingSystem
TYPE : string
QUALIFIER : QUALIFIER
VALUE : 2600
# back to XML
MSH>,$os.INSTANCE.property[10].get_OuterXml()
<PROPERTY NAME="BuildNumber" CLASSORIGIN="Win32_OperatingSystem" TYPE="string"><QUALIFIER NAME="CIMTYPE" PROPAGATED="true" TYPE="string" TO
INSTANCE="true"><VALUE>string</VALUE></QUALIFIER><VALUE>2600</VALUE></PROPERTY>
# count properties
MSH>$os.INSTANCE.property.count
70
# list propertynames
MSH>$os.INSTANCE.property | foreach {$_.name}
__PATH
__NAMESPACE
__SERVER
__PROPERTY_COUNT
__RELPATH
__DYNASTY
__SUPERCLASS
__CLASS
__GENUS
BootDevice
BuildNumber
BuildType
Caption
CodeSet
CountryCode
....
# Save The XML to a XML file
$os.save("c:\os.xml")
October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 April 2006 May 2006 June 2006 July 2006 August 2006 September 2006 October 2006 November 2006 December 2006