{"id":10121,"date":"2006-06-25T23:13:00","date_gmt":"2006-06-25T23:13:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2006\/06\/25\/improved-support-for-wmi\/"},"modified":"2019-02-18T13:21:36","modified_gmt":"2019-02-18T20:21:36","slug":"improved-support-for-wmi","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/improved-support-for-wmi\/","title":{"rendered":"Improved Support for WMI"},"content":{"rendered":"<p>&lt;Edited 7\/2\/2006 to add tags and categories&gt;<br \/>We have recently completed work on improved support for WMI including:<\/p>\n<ol>\n<li>Improved Adapters for WMI objects and classes\n<ol>\n<li>Most notably the ability to easily invoke methods on both<\/li>\n<\/ol>\n<li>Direct language support for WMI\n<ol>\n<li>Type accelerators for [WMI], [WMICLASS], and [WMISEARCHER]<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><strong>Everyone that uses WMI owes a debt of gratitude to Greg Ramsey<\/strong>.&nbsp; Greg did&nbsp;an MMS session and lab focused on Scripting SMS using VBscript and Windows PowerShell.&nbsp; Jim Truher and I joined Greg to host a Birds of a Feather (BOF) session on Scripting.&nbsp; Greg was quite <span>enthusiastic <\/span>about the power of Windows PowerShell but during the BOF someone asked him directly, &#8220;So which is it &#8211; should we be using VBscript or Windows PowerShell to script SMS&#8221;.&nbsp; I forgot exactly what Greg said&nbsp;but it was along the line so of, &#8220;<em>if you want to do reporting, use Windows PowerShell because it is very powerful but if you want to get things done, use VBScript because&nbsp;you can&#8217;t invoke&nbsp;WMI methods (at least not easily)&#8221;.<\/em><\/p>\n<p>This was a real wake up call for us.&nbsp; Greg is exactly the sort of person that we want to be a ardent, unabashed, no reservations, hard core Windows PowerShell user and the message was loud and clear &#8211; <em>almost but not quite<\/em>.&nbsp; <\/p>\n<p>We knew that our WMI support was not what we wanted it to be but as I&#8217;ve mentioned many times, to ship is to choose.&nbsp; We thought that we had reasonable support and that WMI users wouldn&#8217;t be phased by some of the <span>deficiencies <\/span>&#8211; yes calling methods was complex but we figured that if you were using WMI, you were self-qualified as being able to cope with complexity \ud83d\ude42 .&nbsp; <\/p>\n<p>Just to be precise, you could always call WMI methods but you had to do so using the Invoke_Method() call pass it the name of the Method and then all the parameters encoded as an array.&nbsp;&nbsp;&nbsp;It was probably&nbsp;total folly to think that this was an acceptable user-experience but it took Greg&#8217;s comment to get things moving on the right track. <\/p>\n<p>In RC2 this is what a WMI object looks like:<\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt; <strong><font color=\"#000080\">$g=Get-WmiObject Win32_process -filter &#8216;Name = &#8220;calc.exe&#8221;&#8216;<br \/><\/font><\/strong>PS&gt; <strong><font color=\"#000080\">$g |gm -membertype &#8220;Method,Property&#8221;<br \/><\/font><\/strong><\/font><br \/><font face=\"Courier New\" size=\"1\">&nbsp;&nbsp; TypeName: System.Management.ManagementObject#root\\cimv2\\Win32_Process<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType Definition<br \/>&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br \/><font color=\"#ff0000\">AttachDebugger&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementBaseOb&#8230;<br \/>GetOwner&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementBaseOb&#8230;<br \/>GetOwnerSid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementBaseOb&#8230;<br \/>SetPriority&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementBaseOb&#8230;<br \/>Terminate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementBaseOb&#8230;<br \/><\/font>__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String __CLASS {get;}<br \/>__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String[] __DERIVATION {get;}<br \/>__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String __DYNASTY {get;}<br \/>__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Int32 __GENUS {get;}<br \/>__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String __NAMESPACE {get;}<br \/>__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String __PATH {get;}<br \/>__PROPERTY_COUNT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Int32 __PROPERTY_COUNT {get;}<br \/>__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String __RELPATH {get;}<br \/>&#8230;&#8230;&#8230;.<\/font><\/p>\n<p>Notice that the Methods are now the WMI methods for that particular WMIObject (and not the Methods for WMI).&nbsp; If you want those, you can still get them using PSBASE (Remember &#8211; PSBASE is the way to bybass our type Adapter and get an the native capabilities of an object).<\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt; <font color=\"#000080\"><strong>$g.psbase |gm -membertype Method<br \/><\/strong><\/font><\/font><br \/><font face=\"Courier New\" size=\"1\">&nbsp;&nbsp; TypeName: System.Management.Automation.PSMemberSet<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType Definition<br \/>&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br \/>add_Disposed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void add_Disposed(EventHandl&#8230;<br \/>Clone&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object Clone()<br \/>CompareTo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Boolean CompareTo(Management&#8230;<br \/>CopyTo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementPath Co&#8230;<br \/>CreateObjRef&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Runtime.Remoting.ObjRef Crea&#8230;<br \/>Delete&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void Delete(), System.Void D&#8230;<br \/>Dispose&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void Dispose()<br \/>Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Boolean Equals(Object obj)<br \/>Get&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void Get(), System.Void Get(&#8230;<br \/>get_ClassPath&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementPath ge&#8230;<br \/>get_Container&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.ComponentModel.IContainer ge&#8230;<br \/>get_Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object get_Item(String prope&#8230;<br \/>get_Options&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ObjectGetOptions &#8230;<br \/>get_Path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementPath ge&#8230;<br \/>get_Properties&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.PropertyDataColle&#8230;<br \/>get_Qualifiers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.QualifierDataColl&#8230;<br \/>get_Scope&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementScope g&#8230;<br \/>get_Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.ComponentModel.ISite get_Site()<br \/>get_SystemProperties&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.PropertyDataColle&#8230;<br \/>GetHashCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Int32 GetHashCode()<br \/>GetLifetimeService&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object GetLifetimeService()<br \/>GetMethodParameters&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementBaseObj&#8230;<br \/>GetPropertyQualifierValue Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object GetPropertyQualifierV&#8230;<br \/>GetPropertyValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object GetPropertyValue(Stri&#8230;<br \/>GetQualifierValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object GetQualifierValue(Str&#8230;<br \/>GetRelated&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementObjectC&#8230;<br \/>GetRelationships&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementObjectC&#8230;<br \/>GetText&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.String GetText(TextFormat fo&#8230;<br \/>GetType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Type GetType()<br \/>InitializeLifetimeService Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object InitializeLifetimeSer&#8230;<br \/>InvokeMethod&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object InvokeMethod(String m&#8230;<br \/>Put&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementPath Pu&#8230;<br \/>remove_Disposed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void remove_Disposed(EventHa&#8230;<br \/>set_Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void set_Item(String propert&#8230;<br \/>set_Options&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void set_Options(ObjectGetOp&#8230;<br \/>set_Path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void set_Path(ManagementPath&#8230;<br \/>set_Scope&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void set_Scope(ManagementSco&#8230;<br \/>set_Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void set_Site(ISite value)<br \/>SetPropertyQualifierValue Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void SetPropertyQualifierVal&#8230;<br \/>SetPropertyValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void SetPropertyValue(String&#8230;<br \/>SetQualifierValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Void SetQualifierValue(Strin&#8230;<br \/>ToString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.String ToString()<\/font><\/p>\n<p>But now that the Instance properties are exposed, WMI objects act more like&nbsp;&#8220;normal&#8221; objects:<\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt;<font color=\"#000080\"> <strong>$g.GetOwner()<\/strong><\/font><\/font><br \/><font face=\"Courier New\" size=\"1\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2<br \/>__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : __PARAMETERS<br \/>__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : __PARAMETERS<br \/>__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__PROPERTY_COUNT : 3<br \/>__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {}<br \/>__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>Domain&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : NTDEV<br \/>ReturnValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 0<br \/>User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : jsnover<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt; <strong><font color=\"#000080\">$g.Terminate()<\/font><\/strong><\/font><br \/><font face=\"Courier New\" size=\"1\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2<br \/>__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : __PARAMETERS<br \/>__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : __PARAMETERS<br \/>__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__PROPERTY_COUNT : 1<br \/>__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {}<br \/>__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>ReturnValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 0<br \/><\/font><\/p>\n<p>&nbsp;<\/p>\n<p>We have also changed the Adapted view of WMI Classes.&nbsp; These used to share the same adapter as WMI Instances which meant that you saw&nbsp;instance properties, which makes no sense.&nbsp; Here is what a WMI Class now looks like:<br \/><font face=\"Courier New\"><font size=\"1\"><br \/>PS&gt; <\/font><font size=\"1\"><font color=\"#000080\"><strong>$c&nbsp; = Get-WmiObject -list |where {$_.Name -eq &#8220;Win32_Process&#8221;}<br \/><\/strong><\/font>PS&gt; <font color=\"#000080\"><strong>$c |Format-List *<\/strong><\/font><\/font><\/font><br \/><font face=\"Courier New\" size=\"1\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_Process<br \/>__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 1<br \/>__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_Process<br \/>__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; : CIM_Process<br \/>__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : CIM_ManagedSystemElement<br \/>__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_Process<br \/>__PROPERTY_COUNT : 45<br \/>__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {CIM_Process, CIM_LogicalElement, CIM_ManagedSystemEleme<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nt}<br \/>__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : JPSLAP04<br \/>__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ROOT\\cimv2<br \/>__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <\/font><a href=\"Win32_Process\"><font face=\"Courier New\" size=\"1\">\\\\JPSLAP04\\ROOT\\cimv2:Win32_Process<\/font><\/a><\/p>\n<p><font size=\"1\"><font face=\"Courier New\">PS&gt;<strong><font color=\"#000080\"> $c | Get-Member -MemberType Method<\/font><\/strong><\/font><br \/><font face=\"Courier New\">&nbsp;&nbsp; TypeName: System.Management.ManagementClass#ROOT\\cimv2\\Win32_Process<\/font><\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">Name&nbsp;&nbsp; MemberType Definition<br \/>&#8212;-&nbsp;&nbsp; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br \/>Create Method&nbsp;&nbsp;&nbsp;&nbsp; System.Management.ManagementBaseObject Create(System.S&#8230;<\/font><\/p>\n<p>And you can use it just as you would expect<\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt; <strong><font color=\"#000080\">$c.Create(&#8220;Calc.exe&#8221;)<\/font><\/strong><\/font><br \/><font face=\"Courier New\" size=\"1\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2<br \/>__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : __PARAMETERS<br \/>__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : __PARAMETERS<br \/>__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__PROPERTY_COUNT : 2<br \/>__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {}<br \/>__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br \/>ProcessId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2948<br \/>ReturnValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 0<\/font><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>In addition to these, we decided to add direct language support for WMI into Windows PowerShell.&nbsp; <\/p>\n<p>[WMISEARCHER] is a type accelerator for a ManagementObjectSearcher. It can take a string constructor to create a searcher that you can then do a GET() on:<\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt; <strong><font color=\"#000080\">$s = [WmiSearcher]&#8217;Select * from Win32_Process where Handlecount &gt; 1000&#8242;<\/font><\/strong><\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt; <strong><font color=\"#000080\">$s.Get() |sort handlecount |ft handlecount,__path,name -auto<\/font><\/strong><\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">handlecount __PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name<br \/>&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;-<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1105 <\/font><a href='Win32_Process.Handle=\"3724'><font face=\"Courier New\" size=\"1\">\\\\JPSLAP04\\root\\cimv2:Win32_Process.Handle=&#8221;3724<\/font><\/a><font face=\"Courier New\" size=\"1\">&#8221; powershell&#8230;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1132 <\/font><a href='Win32_Process.Handle=\"1388'><font face=\"Courier New\" size=\"1\">\\\\JPSLAP04\\root\\cimv2:Win32_Process.Handle=&#8221;1388<\/font><\/a><font face=\"Courier New\" size=\"1\">&#8221; winlogon.exe<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1495 <\/font><a href='Win32_Process.Handle=\"2852'><font face=\"Courier New\" size=\"1\">\\\\JPSLAP04\\root\\cimv2:Win32_Process.Handle=&#8221;2852<\/font><\/a><font face=\"Courier New\" size=\"1\">&#8221; iexplore.exe<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1699 <\/font><a href='Win32_Process.Handle=\"1204'><font face=\"Courier New\" size=\"1\">\\\\JPSLAP04\\root\\cimv2:Win32_Process.Handle=&#8221;1204<\/font><\/a><font face=\"Courier New\" size=\"1\">&#8221; OUTLOOK.EXE<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1719 <\/font><a href='Win32_Process.Handle=\"1912'><font face=\"Courier New\" size=\"1\">\\\\JPSLAP04\\root\\cimv2:Win32_Process.Handle=&#8221;1912<\/font><\/a><font face=\"Courier New\" size=\"1\">&#8221; iexplore.exe<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2579 <\/font><a href='Win32_Process.Handle=\"1768'><font face=\"Courier New\" size=\"1\">\\\\JPSLAP04\\root\\cimv2:Win32_Process.Handle=&#8221;1768<\/font><\/a><font face=\"Courier New\" size=\"1\">&#8221; svchost.exe<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\"><\/font>&nbsp;<\/p>\n<p>[WMI] is a type accelerator for ManagementObject. This has a string constructor taking a local or absolute WMI Path to a WMI instace and returning a object bound to that instance:<\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt; <strong><font color=\"#000080\">$p = [WMI]&#8217;\\\\JPSLAP04\\root\\cimv2:Win32_Process.Handle=&#8221;1204&#8243;&#8216;<br \/><\/font><\/strong>PS&gt; <strong><font color=\"#000080\">$p.Name<br \/><\/font><\/strong>OUTLOOK.EXE<\/font><\/p>\n<p>&nbsp;<\/p>\n<p>[WMICLASS] is a type accelerator for ManagementClass. This has a string constructor taking a local or absolute WMI Path to a&nbsp;WMI class and returning a object bound to that class:<\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt; <font color=\"#000080\"><strong>$c = [WMICLASS]&#8221;root\\cimv2:WIn32_Process&#8221;<br \/><\/strong><\/font>PS&gt; $<strong><font color=\"#000080\">c |fl *<\/font><\/strong><\/font><br \/><font face=\"Courier New\" size=\"1\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_Process<br \/>__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 1<br \/>__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_Process<br \/>__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp; : CIM_Process<br \/>__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : CIM_ManagedSystemElement<br \/>__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_Process<br \/>__PROPERTY_COUNT : 45<br \/>__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp; : {CIM_Process, CIM_LogicalElement, CIM_ManagedSystemEleme<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nt}<br \/>__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : JPSLAP04<br \/>__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ROOT\\cimv2<br \/>__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <\/font><a href=\"Win32_Process\"><font face=\"Courier New\" size=\"1\">\\\\JPSLAP04\\ROOT\\cimv2:Win32_Process<\/font><\/a><\/p>\n<p>We think that these changes&nbsp;make Windows PowerShell THE best environment to use and script WMI.&nbsp; When RC2 comes out towards the end of the summer, you&#8217;ll be able to kick the tires on these new features and let us know if you agree.&nbsp; <\/p>\n<p>I want to highlight the role of user feedback in these changes.&nbsp; If it wasn&#8217;t for Greg speaking up and giving us honest feedback about where we were not doing a good enough job, these changes would not have been made.&nbsp; So hat&#8217;s off to Greg but also &#8211; if there is something about Windows PowerShell that you don&#8217;t like &#8211; let us know &#8211; we really are listening.<\/p>\n<p>Enjoy!<\/p>\n<p>Jeffrey Snover<br \/>Windows PowerShell Architect<\/p>\n<p>PSMDTAG:FAQ: How do i invoke a method on a WMI class?<br \/>PSMDTAG:FAQ: How do i invoke a method on a WMI object?<br \/>PSMDTAG:FAQ: How&nbsp;can I use WQL?<br \/>PSMDTAG:FAQ: How do I use WMI?<br \/>PSMDTAG:FAQ: How do I bind to a WMI Instance from a WMI PATH?<br \/>PSMDTAG:TYPE:WMI [WMI] [WMICLASS] [WMISEARCHER]<br \/>PSMDTAG:TYPE:WMI&nbsp; Invoking methods<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;Edited 7\/2\/2006 to add tags and categories&gt;We have recently completed work on improved support for WMI including: Improved Adapters for WMI objects and classes Most notably the ability to easily invoke methods on both Direct language support for WMI Type accelerators for [WMI], [WMICLASS], and [WMISEARCHER] Everyone that uses WMI owes a debt of gratitude [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[10,20],"class_list":["post-10121","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-faq","tag-typewmi"],"acf":[],"blog_post_summary":"<p>&lt;Edited 7\/2\/2006 to add tags and categories&gt;We have recently completed work on improved support for WMI including: Improved Adapters for WMI objects and classes Most notably the ability to easily invoke methods on both Direct language support for WMI Type accelerators for [WMI], [WMICLASS], and [WMISEARCHER] Everyone that uses WMI owes a debt of gratitude [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/10121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=10121"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/10121\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=10121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=10121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=10121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}