{"id":15331,"date":"2011-03-13T00:01:00","date_gmt":"2011-03-13T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2011\/03\/13\/get-all-methods-and-writable-properties-from-all-wmi-classes\/"},"modified":"2011-03-13T00:01:00","modified_gmt":"2011-03-13T00:01:00","slug":"get-all-methods-and-writable-properties-from-all-wmi-classes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/get-all-methods-and-writable-properties-from-all-wmi-classes\/","title":{"rendered":"Get All Methods and Writable Properties from All WMI Classes"},"content":{"rendered":"<p><b>Summary<\/b>: Use Windows PowerShell to gather all implemented methods and writable properties from all WMI namespaces.<\/p>\n<h3>Weekend Scripter <\/h3>\n<p>Microsoft Scripting Guy, Ed Wilson, here. It is quiet around here on the weekends. At times, it is extremely quiet. I decided to use the time to make some serious changes to my WMI method and property discovery script I have been working on the previous several days. <\/p>\n<p><a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2011\/03\/10\/use-powershell-to-find-wmi-classes-that-contain-methods.aspx\">On Thursday<\/a>, I wrote a script that gathers implemented methods from all of the dynamic WMI classes in a single WMI namespace. By default, this WMI namespace is root\\cimv2. <a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2011\/03\/11\/use-powershell-to-find-writable-wmi-properties.aspx\">On Friday<\/a>, I wrote a script that retrieves all of the writable properties from all of the dynamic WMI classes in a single WMI namespace. <a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2011\/03\/12\/explore-wmi-methods-and-properties-via-powershell-script.aspx\">On Saturday<\/a>, I combined these two scripts and added the ability to write to a text file. <\/p>\n<p>Today I thought I would modify yesterday&rsquo;s script to query all WMI namespaces. Because this can take a rather long time, I also decided to implement a nested progress bar. It is a cool script. It is also rather long; therefore, I uploaded it to the <a target=\"_blank\" href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/b4bfc9f5-5ace-4041-ba65-375ef74c1c8e\">Scripting Guys Script Repository<\/a>. <\/p>\n<p>The big change involves creating a function that generates a recursive listing of all WMI namespaces on the target computer (by default this is the local computer). A recursive listing is required because of the deeply nested structure that is used by the WMI namespaces. This structure is illustrated in the following graphic.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0407.WES-3-13-11-01_11D65C44.jpg\"><img decoding=\"async\" height=\"671\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2541.WES-3-13-11-01_thumb_1B6EA4AD.jpg\" alt=\"Image of nested structure\" border=\"0\" title=\"Image of nested structure\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>I decided to filter out the root\\directory WMI namespace, in addition to all namespaces below this namespace. The reason is because during my testing, it was taking an extremely long time to complete the enumeration of the classes in those namespaces, and in the end, nothing was showing up that was usable. <\/p>\n<p>If you want to add it back, I have added a comment that will help you locate the line to remove. The technique of filtering out a namespace is useful anyway, because you may wish to create custom reports and exclude certain namespaces&mdash;therefore, it is all good. <\/p>\n<p>The <b>Get-WmiNamespace<\/b> function is similar to one I wrote for the <a target=\"_blank\" href=\"http:\/\/www.amazon.com\/Windows-Resource-Kit-Mitch-Tulloch\/dp\/0735627002\">Windows 7 Resource Kit<\/a>. I added the value &ldquo;SilentlyContinue&rdquo; for the <i>ErrorAction<\/i> parameter because you will not always have rights to all WMI namespaces, and I wanted to suppress the errors. The complete text for the <b>Get-WmiNamespace<\/b> function is shown here:<\/p>\n<blockquote>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">Function Get-WmiNameSpace<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">{<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">Param(<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">$nameSpace = &#8220;root&#8221;,<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">$computer = &#8220;localhost&#8221;<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">)<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">Get-WmiObject -class __NameSpace -computer $computer `<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">-namespace $namespace -ErrorAction &#8220;SilentlyContinue&#8221; |<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">Foreach-Object `<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">-Process `<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">{ <\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">$subns = Join-Path -Path $_.__namespace -ChildPath $_.name<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">#Following line skips the root\\directory &amp; root\\directory\\LDAP namespaces<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">if($subns -notmatch &#8216;directory&#8217;) {$subns} <\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">$namespaces += $subns + &#8220;`r`n&#8221;<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">Get-WmiNameSpace -namespace $subNS -computer $computer<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">} <\/span><\/span><\/span><\/span><\/p>\n<p><span style=\"line-height: normal;list-style-type: disc;font-family:\"><span style=\"font-family: Segoe\"><span style=\"color: #000000;font-size: 10pt\">} #end Get-WmiNameSpace<\/span><\/span><\/span><\/p><\/blockquote>\n<p>The entry point to the script sees me setting the value &ldquo;SilentlyContinue&rdquo; to the global <i>$ErrorActionPreference<b> <\/b><\/i>variable. I do this to suppress any errors that may occur while running the script. Obviously, when writing the script one wants to see the errors, and indeed most of the time I want to see the errors. Therefore, I set it back to the default value of &ldquo;Continue&rdquo; at the bottom of the script. <\/p>\n<p>Next, I set a path for the log file, display a message that states I am gathering WMI namespaces, and I call the <b>Get-WMiNamespace<\/b> function. After the collection of namespaces is generated, I initialize the <i>$j<\/i> variable that is used to keep track of my progress through the WMI namespaces. This portion of the script is shown here.<\/p>\n<blockquote>\n<p>$ErrorActionPreference = &#8220;SilentlyContinue&#8221;<\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">$ErrorActionPreference = &#8220;SilentlyContinue&#8221;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">$path = &#8220;C:\\fso\\WMiMethodsAndPropertiesInAllNamespaces.txt&#8221;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">&#8220;Collecting WMI Namespaces&#8221;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">$CollectionOfNamespaces = Get-WmiNameSpace<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">$j = 0<\/span><\/span><\/span><\/p>\n<\/blockquote>\n<p>I use the <i>ForEach<\/i> statement to walk through the collection of WMI namespaces. I now write to the log file by using the redirection arrow. This first message provides the name of the WMI namespace. Next, I use the <b>Write-Progress<\/b> cmdlet to track my progress through the WMI namespaces. <\/p>\n<p>For information about using the <b>Write-Progress<\/b> cmdlet to create a nested progress bar, see the <a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2011\/01\/30\/provide-progress-for-your-script-with-a-powershell-cmdlet.aspx\">Provide Progress for Your Script with a PowerShell Cmdlet<\/a> Hey, Scripting Guy! blog. Basic information about the <b>Write-Progress<\/b> cmdlet appears in the <a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2011\/01\/29\/add-a-progress-bar-to-your-powershell-script.aspx\">Add a Progress Bar to Your PowerShell Script<\/a> Hey, Scripting Guy! blog. <\/p>\n<p>This portion of the script is shown here.<\/p>\n<blockquote>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">Foreach($namespace in $collectionOfNamespaces)<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">{<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">&#8220;Checking $namespace&#8221; &gt;&gt; $path<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">Write-Progress -Activity &#8220;Inspecting Properties and Methods&#8221; `<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">-Status &#8220;Checking namespace $($namespace)&#8221; `<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">-PercentComplete ($j \/ $CollectionOfNamespaces.Length*100) -Id 1 `<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">-ErrorAction &#8220;SilentlyContinue&#8221;<\/span><\/span><\/span><\/span><\/p>\n<\/blockquote>\n<p>Now I initialize the <i>$I<\/i> variable, which is used as a counter to mark progress through the collection of WMI classes. I then retrieve a listing of all the WMI classes in the namespace, and I store the resulting classes in the <i>$classes<\/i> variable. As I walk through the collection of classes, I use a nested <b>Write-Progress<\/b> bar to mark my progress through the collection of classes. I then call the <b>Get-WMIClassMethods<\/b> function and the <b>Get-WmiClassProperties<\/b> function and clean everything up. This portion of the script is shown here.<\/p>\n<blockquote>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">$i = 0<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">$classes = Get-WmiObject -List -Namespace $namespace -EA &#8220;SilentlyContinue&#8221;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">Foreach($class in $classes)<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">{<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">Write-Progress -Activity &#8220;Inspecting Properties and Methods&#8221; `<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">-Status &#8220;Checking $($class.name)&#8221; `<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">-PercentComplete ($i \/ $classes.count*100) -ErrorAction &#8220;SilentlyContinue&#8221; `<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">-ParentId 1<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">Get-WmiClassMethods -class $class &gt;&gt;$path<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">Get-WmiClassProperties -class $class &gt;&gt;$path<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">$i++<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp;<\/span><\/span><span style=\"font-size: 10pt\">} #end foreach class<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span><span style=\"font-size: 10pt\">&nbsp; <\/span><\/span><span style=\"font-size: 10pt\">$j++<\/span><\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">} #end foreach namespace<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"line-height: 10pt;list-style-type: disc;margin: 4pt 0in 7pt\"><span><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000;font-size: 10pt\">$ErrorActionPreference = &#8220;Continue&#8221;<\/span><\/span><\/span><\/p>\n<\/blockquote>\n<p>When the script runs, the first thing that appears in the Windows PowerShell ISE display panel (in fact the only thing that appears) is the message that states I am gathering WMI namespaces. This is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4201.WES-3-13-11-02_4ADD1379.jpg\"><img decoding=\"async\" height=\"434\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5706.WES-3-13-11-02_thumb_0ED0D1C4.jpg\" alt=\"Image of message\" border=\"0\" title=\"Image of message\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>After all of the WMI namespaces are gathered, the nested progress bar appears. The top progress bar indicates progress through the namespaces, and the bottom bar indicates the progress through the collection of dynamic WMI classes inside the current namespace. The nested progress bar is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2480.WES-3-13-11-03_6C2C9348.jpg\"><img decoding=\"async\" height=\"422\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5224.WES-3-13-11-03_thumb_373F8E0B.jpg\" alt=\"Image of nested progress bar\" border=\"0\" title=\"Image of nested progress bar\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>When the script completes its run, the implemented WMI methods and writable properties for each class in each namespace appear in the text file that you specified to the <i>$path<\/i> variable. A copy of my text file is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7282.WES-3-13-11-04_38C0AA1F.jpg\"><img decoding=\"async\" height=\"636\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7215.WES-3-13-11-04_thumb_5248374C.jpg\" alt=\"Image of text file\" border=\"0\" title=\"Image of text file\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>That is about all there is to exploring WMI for implemented methods and writable properties. Join me tomorrow when I will talk about using a few of our newly discovered writable properties to make useful configuration changes. It is cool, and I am sure you do not want to miss it.<\/p>\n<p>I invite you to follow me on <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingforum\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use Windows PowerShell to gather all implemented methods and writable properties from all WMI namespaces. Weekend Scripter Microsoft Scripting Guy, Ed Wilson, here. It is quiet around here on the weekends. At times, it is extremely quiet. I decided to use the time to make some serious changes to my WMI method and property [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[3,4,61,45,6],"class_list":["post-15331","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-scripting-guy","tag-scripting-techniques","tag-weekend-scripter","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: Use Windows PowerShell to gather all implemented methods and writable properties from all WMI namespaces. Weekend Scripter Microsoft Scripting Guy, Ed Wilson, here. It is quiet around here on the weekends. At times, it is extremely quiet. I decided to use the time to make some serious changes to my WMI method and property [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/15331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=15331"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/15331\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=15331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=15331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=15331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}