{"id":15361,"date":"2011-03-10T00:01:00","date_gmt":"2011-03-10T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2011\/03\/10\/use-powershell-to-find-wmi-classes-that-contain-methods\/"},"modified":"2011-03-10T00:01:00","modified_gmt":"2011-03-10T00:01:00","slug":"use-powershell-to-find-wmi-classes-that-contain-methods","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-find-wmi-classes-that-contain-methods\/","title":{"rendered":"Use PowerShell to Find WMI Classes that Contain Methods"},"content":{"rendered":"<p><span style=\"font-size: small\"><b>Summary<\/b>: Learn how to use Windows PowerShell to find WMI classes that contain usable methods for making configuration changes in Windows.<\/span><\/p>\n<p><span style=\"font-size: small\"><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Question\" border=\"0\" title=\"Hey, Scripting Guy! Question\" \/>&nbsp; Hey, Scripting Guy! I that know you spend a lot of time working with WMI. The one thing that I really do not like about WMI is that although it seems like there is a lot of information that can be retrieved, it seems that there are not very many things that WMI can actually do. I guess what I am really interested in is: Are there WMI classes that have methods?<\/span><\/p>\n<p><span style=\"font-size: small\">&mdash;SH<\/span><\/p>\n<p><span style=\"font-size: small\"><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\" \/> Hello SH, <\/span><\/p>\n<p><span style=\"font-size: small\">Microsoft Scripting Guy, Ed Wilson, here. It is less than a month until the 2011 Scripting Games, and things are really heating up. While I was in Seattle last week visiting with the Microsoft MVPs, I was able to round up a large number of judges and expert commentators. I have already begun emailing the events to the expert commentators, and I am compiling my list of judges. The judges and the judging criteria will be posted soon. The one location you need to bookmark is the <\/span><a target=\"_blank\" href=\"http:\/\/blogs.technet.comhttps:\/\/devblogs.microsoft.com\/scripting\/2011-scripting-games-all-links-on-one-page\/\"><span style=\"font-size: small\">2011 Scripting Games: All Links on One Page<\/span><\/a><span style=\"font-size: small\">&nbsp;site. Links to vital information will be presented throughout the next couple of months. <\/span><\/p>\n<p><span style=\"font-size: small\">While sipping a cup of English Breakfast tea and munching a caramel flavored Tim Tam (provided by Microsoft MVP Shane Hoey from Australia), I finally had a chance to write a script I have been wanting to write for a long time. I had written a similar script for my Microsoft Press book, <\/span><a target=\"_blank\" href=\"http:\/\/www.amazon.com\/Microsoft-Windows-Scripting-WMI-Self-Paced\/dp\/0735622310\/ref=sr_1_1?ie=UTF8&amp;qid=1299689021&amp;sr=8-1\"><span style=\"font-size: small\">Windows Scripting with WMI<\/span><\/a><span style=\"font-size: small\">, but I used VBScript for that endeavor, and I wanted to update it to Windows PowerShell. <\/span><\/p>\n<p><span style=\"font-size: small\">One nice change in Windows PowerShell 2.0 is direct access to a methods collection. (In Windows PowerShell 1.0, it was more difficult to obtain this information.) One thing that makes the script a bit complicated is the way that WMI exposes information. <\/span><\/p>\n<p><span style=\"font-size: small\">In the end, the Get-WmiClassMethods.ps1 script is a bit more complicated than I would like it to be, but it works and it accomplishes the job. Feel free to email improvements to the script to <\/span><a href=\"mailto:scripter@microsoft.com\"><span style=\"font-size: small\">scripter@microsoft.com<\/span><\/a><span style=\"font-size: small\">, or better yet, post a revision to the script to the <\/span><a target=\"_blank\" href=\"http:\/\/gallery.technet.microsoft.com\/ScriptCenter\/\"><span style=\"font-size: small\">Scripting Guys Script Repository<\/span><\/a><span style=\"font-size: small\"> so other scripters will have access to your work. <\/span><\/p>\n<p><span style=\"font-size: small\">The complete Get-WmiClassMethods.ps1 script appears here:<\/span><\/p>\n<p><strong><span style=\"font-size: small\">Get-WmiClassMethods.ps1<\/span><\/strong><\/p>\n<blockquote>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"># Script: Get-WmiClassMethods.ps1<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"># Author: ed wilson, msft<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"># Date: 03\/08\/2011 12:46:15<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"># Keywords: Scripting Techniques, WMI<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"># comments: Gets dynamic WMI classes that have methods marked with the implemented<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"># qualifier<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"># HSG-3-10-11<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">function New-Underline<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">{<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">&lt;#<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">.Synopsis<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>Creates an underline the length of the input string<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">.Example<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>New-Underline -strIN &#8220;Hello world&#8221;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">.Example<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>New-Underline -strIn &#8220;Morgen welt&#8221; -char &#8220;-&#8221; -sColor &#8220;blue&#8221; -uColor &#8220;yellow&#8221;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">.Example<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>&#8220;this is a string&#8221; | New-Underline<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">.Notes<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>NAME:<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>AUTHOR: Ed Wilson<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>LASTEDIT: 5\/20\/2009<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>KEYWORDS:<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">.Link<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>Http:\/\/www.ScriptingGuys.com<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">#&gt;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">[CmdletBinding()]<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">param(<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>[Parameter(Mandatory = $true,Position = 0,valueFromPipeline=$true)]<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>[string]<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>$strIN,<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>[string]<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>$char = &#8220;=&#8221;,<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>[string]<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>$sColor = &#8220;Green&#8221;,<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>[string]<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>$uColor = &#8220;darkGreen&#8221;,<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>[switch]<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>$pipe<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>) #end param<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>$strLine= $char * $strIn.length<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>if(-not $pipe)<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>{<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp; <\/span>Write-Host -ForegroundColor $sColor $strIN<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp; <\/span>Write-Host -ForegroundColor $uColor $strLine<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>}<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>Else<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>{<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>$strIn<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>$strLine<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>}<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">} #end new-underline function<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">&nbsp;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">Function Get-WmiClassMethods<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">{ <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>Param(<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp; <\/span>[string]$namespace = &#8220;root\\cimv2&#8221;,<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp; <\/span>[string]$computer = &#8220;.&#8221;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">)<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>$abstract = $false<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>$method = $null<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>$classes = Get-WmiObject -List -Namespace $namespace | Where-Object { $_.methods }<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>Foreach($class in $classes)<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>{<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>Foreach($q in $class.Qualifiers)<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp; <\/span>{ if ($q.name -eq &#8216;Abstract&#8217;) {$abstract = $true} }<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>If(!$abstract) <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp; <\/span>{ <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Foreach($m in $class.methods)<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{ <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Foreach($q in $m.qualifiers) <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{ <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>if($q.name -match &#8220;implemented&#8221;) <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{ <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>$method += $m.name + &#8220;`r`n&#8221;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>} #end if name<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>} #end foreach q<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>} #end foreach m<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>if($method) {New-Underline $class.name}<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>$method<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;&nbsp;&nbsp; <\/span>} #end if not abstract<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>$abstract = $false<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp; <\/span>$method = $null<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\"><span>&nbsp;<\/span>} #end foreach class<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">} #end function Get-WmiClassMethods<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\"><span style=\"font-size: small\">&nbsp;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter;color: #000000\"><span style=\"font-size: small\"># *** Entry Point to Script ***<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\" style=\"line-height: 10pt;list-style-type: disc;margin: 15pt 17.3pt 0.25in 0in;background: none transparent scroll repeat 0% 0%\"><span style=\"font-family: Lucida Sans Typewriter;color: #000000\"><span style=\"font-size: small\">&nbsp;<\/span><\/span><\/p>\n<p><span style=\"line-height: normal;list-style-type: disc;font-family:\"><span style=\"font-family: Lucida Sans Typewriter;color: #000000\"><span style=\"font-size: small\">Get-WmiClassMethods<\/span><\/span><\/span><\/p><\/blockquote>\n<p><span style=\"font-size: small\">The first thing I do in the Get-WmiClassMethods.ps1 script is to create the <b>New-Underline<\/b> function. I wrote this standard function when I was writing all of the scripts for the <\/span><a target=\"_blank\" href=\"http:\/\/www.microsoft.com\/learning\/en\/us\/Books.aspx?Id=13811\"><span style=\"font-size: small\">Windows 7 Resource Kit<\/span><\/a><span style=\"font-size: small\">. I have also used it in a <\/span><a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/search\/searchresults.aspx?q=new-underline&amp;sections=7618\"><span style=\"font-size: small\">number of Hey Scripting Guy! articles<\/span><\/a><span style=\"font-size: small\">; therefore, I will not expound upon it here. <\/span><\/p>\n<p><span style=\"font-size: small\">In the <b>Get-WmiClassMethods<\/b> function, I first create two input parameters. The first one is used for the WMI namespace, and the second one is for the computer name. Both are set to default parameters. I then initialize two variables that are used later in the function. This portion of the script is shown here.<\/span><\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">Function Get-WmiClassMethods<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">{ <\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">Param(<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">[string]$namespace = &#8220;root\\cimv2&#8221;,<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">[string]$computer = &#8220;.&#8221;<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">)<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">$abstract = $false<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">$method = $null<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size: small\">There are numerous WMI namespaces, and therefore the ability to change namespaces is an essential technique. In addition, the ability to run the script against a remote computer makes it a valuable tool because various versions of the operating system (and indeed various features and roles) provide access to different classes and namespaces. <\/span><\/p>\n<p><span style=\"font-size: small\">By using the <i>list <\/i>parameter from the <b>Get-WmiObject<\/b> Windows PowerShell cmdlet, I am able to obtain a listing of all the WMI classes in a namespace. This listing contains abstract classes (that are not usable for scripting), in addition to classes that do not have methods. I use the <b>Where-Object<\/b> cmdlet to limit the results to only WMI classes that have methods. This list is stored in the variable <b>$classes<\/b> as shown here.<\/span><\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">$classes = Get-WmiObject -List -Namespace $namespace | Where-Object { $_.methods }<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size: small\">Next I use the <i>foreach <\/i>statement to walk through the array of WMI classes. For each WMI class (stored in the <b>$class<\/b> variable) I look at the collection of qualifiers that are associated with the WMI class. If a WMI class has the <i>abstract<\/i> qualifier, I eliminate it from further consideration and I set the <b>$abstract<\/b> variable to <b>$true<\/b>. This portion of the script is shown here.<\/span><\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">Foreach($class in $classes)<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">{<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">Foreach($q in $class.Qualifiers)<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">{ if ($q.name -eq &#8216;Abstract&#8217;) {$abstract = $true} }<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size: small\">If the <b>$abstract<\/b> variable is not set to <b>$true<\/b>, I proceed to obtain a collection of all of the methods that are associated with the WMI class (contained in the <b>$class<\/b> variable). To see if a method will work, I look for a qualifier named <i>implemented.<\/i> If the <i>implemented <\/i>qualifier exists, the method should work. If the method is not implemented, it will not work, and there is no point in returning it to my list. I then create a variable called <b>$method<\/b> to hold all of the implemented method names for each WMI class. This portion of the script is shown here.<\/span><\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">If(!$abstract) <\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">{ <\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">Foreach($m in $class.methods)<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">{ <\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">Foreach($q in $m.qualifiers) <\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">{ <\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">if($q.name -match &#8220;implemented&#8221;) <\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">{ <\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">$method += $m.name + &#8220;`r`n&#8221;<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">} #end if name<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">} #end foreach q<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">} #end foreach m<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size: small\">Now it is time to produce the report. I want to list only WMI class names that contain implemented methods. Therefore, I examine the <b>$method<\/b> variable to see if it contains any methods. If it does, I call the <b>New-Underline<\/b> function to underline the WMI class name, and I print the methods that are associated with the class. <\/span><\/p>\n<p><span style=\"font-size: small\">Next, I need to clean out the <b>$abstract<\/b> and the <b>$method<\/b> variables so I can loop through the script for the next WMI class in the list. To call the script, I can use the function name (<b>Get-WmiClassMethods<\/b>) as I did here, or I can call the <b>Get-WmiClassMethods<\/b> function and pass a different computer and a different WMI namespace to it. This portion of the script is shown here.<\/span><\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">if($method) {New-Underline $class.name}<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">$method<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">} #end if not abstract<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">$abstract = $false<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">$method = $null<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">} #end foreach class<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">} #end function Get-WmiClassMethods<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\"># *** Entry Point to Script ***<\/span><\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"font-size: small\">Get-WmiClassMethods<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size: small\">When the script runs, the output that is shown in the following image appears. <\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5153.HSG-3-10-11-01_535B683E.jpg\"><span style=\"font-size: small\"><img decoding=\"async\" height=\"422\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5340.HSG-3-10-11-01_thumb_01F17121.jpg\" alt=\"Image of command output\" border=\"0\" title=\"Image of command output\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/span><\/a><\/p>\n<p><span style=\"font-size: small\">Improvements to the script could be to add the ability to output to a file (redirection would work) and adding a progress indicator (the script takes several seconds to complete). For more information about WMI, refer to the <\/span><a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/\"><span style=\"font-size: small\">Hey, Scripting Guy! blog<\/span><\/a><span style=\"font-size: small\">. <\/span><\/p>\n<p><span style=\"font-size: small\">SH, that is all there is to finding WMI classes that can actually do things. In Windows 7, there are some great new additions to WMI. I invite you to join me tomorrow when we will do a similar thing for properties. It will be really cool. <\/span><\/p>\n<p><span style=\"font-size: small\">I invite you to follow me on <\/span><a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\"><span style=\"font-size: small\">Twitter<\/span><\/a><span style=\"font-size: small\"> and <\/span><a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguysfacebook\"><span style=\"font-size: small\">Facebook<\/span><\/a><span style=\"font-size: small\">. If you have any questions, send email to me at <\/span><a href=\"mailto:scripter@microsoft.com\"><span style=\"font-size: small\">scripter@microsoft.com<\/span><\/a><span style=\"font-size: small\">, or post your questions on the <\/span><a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingforum\"><span style=\"font-size: small\">Official Scripting Guys Forum<\/span><\/a><span style=\"font-size: small\">. See you tomorrow. Until then, peace.<\/span><\/p>\n<p><b><span style=\"font-family: Segoe UI\"><span style=\"font-size: small\">Ed Wilson, Microsoft Scripting Guy<\/span><\/span><\/b><\/p>\n<p><span style=\"font-size: small\">&nbsp;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn how to use Windows PowerShell to find WMI classes that contain usable methods for making configuration changes in Windows. &nbsp; Hey, Scripting Guy! I that know you spend a lot of time working with WMI. The one thing that I really do not like about WMI is that although it seems like there [&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,45,6],"class_list":["post-15361","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: Learn how to use Windows PowerShell to find WMI classes that contain usable methods for making configuration changes in Windows. &nbsp; Hey, Scripting Guy! I that know you spend a lot of time working with WMI. The one thing that I really do not like about WMI is that although it seems like there [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/15361","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=15361"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/15361\/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=15361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=15361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=15361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}