{"id":15351,"date":"2011-03-11T00:01:00","date_gmt":"2011-03-11T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2011\/03\/11\/use-powershell-to-find-writable-wmi-properties\/"},"modified":"2011-03-11T00:01:00","modified_gmt":"2011-03-11T00:01:00","slug":"use-powershell-to-find-writable-wmi-properties","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-find-writable-wmi-properties\/","title":{"rendered":"Use PowerShell to Find Writable WMI Properties"},"content":{"rendered":"<p><b>Summary<\/b>: Learn how to use Windows PowerShell to find WMI classes that allow you to change property values.<\/p>\n<p><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 recently saw a Windows PowerShell script that looked like it actually changed the value of a property. I know that Windows PowerShell methods require you to put things in parentheses, and this script did not have any parentheses. The fact that it used an equal sign (=) makes me think that it was changing a property, but it seems like it should have used a method to make a change. Is this a Windows PowerShell thing, or a WMI thing, or did the script actually not work?<\/p>\n<p>&mdash;JE<\/p>\n<p><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 JE, <\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, here. I appreciate your confidence in me. Without even providing me with the text of a script, you ask me if it will work or not! <a target=\"_blank\" href=\"http:\/\/en.wikipedia.org\/wiki\/Dude\">Dude<\/a> (or dudette), I have been asked all kinds of wild questions in the past, but never has anyone asked me to tell them if a script will work sight unseen. However, I think I might understand your confusion. <\/p>\n<p>Windows Management Instrumentation (WMI) actually exposes a few properties that are read\/write. This means I can actually change things by setting a new value for a property. Although WMI methods show up in a convenient location in the MSDN documentation, and even in the WMI Tester (WbemTest), there is no centralized location for read\/write WMI properties. Methods for the Win32_Volume WMI class are shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8468.HSG-3-11-11-01_786F823C.jpg\"><img decoding=\"async\" height=\"556\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1425.HSG-3-11-11-01_thumb_7C2D270C.jpg\" alt=\"Image of properties and methods\" border=\"0\" title=\"Image of properties and methods\" 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>In the end, if one wishes to find properties that can do things, one has to click them one-by-one. <a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/08\/04\/hey-scripting-guy-how-do-i-use-wmi-with-windows-powershell-to-return-information-about-properties.aspx\">Using wbemtest<\/a> to find a read\/write property entails double-clicking every single property in the property list of Properties section. When the Property Editor appears, if the property has the write Qualifier (in the Qualifiers section) the property is read\/write. The Property Editor for the <b>DriveLetter<\/b> property of the Win32_Volume WMI class is shown in the following image. As you can see, this property is writable. <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3678.HSG-3-11-11-02_324E9F5C.jpg\"><img decoding=\"async\" height=\"469\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7206.HSG-3-11-11-02_thumb_7DCDCD13.jpg\" alt=\"Image of Property Editor\" border=\"0\" title=\"Image of Property Editor\" 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>The only problem with this approach is that the Win32_Volume WMI class has 44 regular properties and 10 system properties. I discovered this by using the following code.<\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">PS C:\\Users\\ed.NWTRADERS&gt; gwmi win32_volume -Filter &#8220;driveletter = &#8216;c:'&#8221; | select -ExpandProperty properties | measure-object<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Count : 44<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Average : <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Sum : <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Maximum : <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Minimum : <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Property :<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">PS C:\\Users\\ed.NWTRADERS&gt; gwmi win32_volume -Filter &#8220;driveletter = &#8216;c:'&#8221; | select systemproperties | measure-object<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Count : 1<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Average : <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Sum : <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Maximum : <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Minimum : <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Property :<\/span><\/p>\n<\/blockquote>\n<p>I decided to fix this situation by writing a Get-WmiClassProperties.ps1 script that will retrieve all of the read\/write WMI properties from all WMI classes in a particular WMI namespace. The complete Get-WmiClassProperties.ps1 script is similar to the Get-WmiClassMethods.ps1 script from <a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2011\/03\/10\/use-powershell-to-find-wmi-classes-that-contain-methods.aspx\">yesterday&rsquo;s Hey Scripting Guy! blog<\/a>. <\/p>\n<p>The complete Get-WmiClassMethods.ps1 is shown here. For ease of copying, the complete script is uploaded to the <a target=\"_blank\" href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/816fb8b6-cdcf-4156-a9a3-a852ce1d2baa\"><strong><span style=\"color: #006bad\">Scripting Guys Script Repository<\/span><\/strong><\/a>. <\/p>\n<p><strong>Get-WmiClassMethods.ps1<\/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: x-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: x-small\"># Script: Get-WmiClassProperties.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: x-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: x-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: x-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: x-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: x-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: x-small\"># HSG-3-11-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-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: x-small\">Function Get-WmiClassProperties<\/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: x-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: x-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: x-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: x-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: x-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: x-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: x-small\"><span>&nbsp;<\/span>$property = $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: x-small\"><span>&nbsp;<\/span>$classes = Get-WmiObject -List -Namespace $namespace <\/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: x-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: x-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: x-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: x-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: x-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: x-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: x-small\"><span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Foreach($p in $class.Properties)<\/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: x-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: x-small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Foreach($q in $p.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: x-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: x-small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>if($q.name -match &#8220;write&#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: x-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: x-small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>$property += $p.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: x-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: x-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: x-small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>} #end foreach p<\/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: x-small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>if($property) {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: x-small\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>$property<\/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: x-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: x-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: x-small\"><span>&nbsp; <\/span>$property = $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: x-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: x-small\">} #end function Get-WmiClassProperties<\/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: x-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: x-small\"># *** Entry Point to Script ***<\/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: x-small\">Get-WmiClassProperties<\/span><\/span><\/span><\/p>\n<\/blockquote>\n<p>The script begins by creating the <a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/search\/searchresults.aspx?q=%22new-underline%22&amp;sections=7618\">New-Underline function<\/a> that has been used in several scripts that appear in the Hey Scripting Guy! blog. <\/p>\n<p>The <b>Get-WmiClassProperties<\/b> function begins by creating a couple of parameters, initializing a couple of variables, and obtaining a collection of all the WMI classes in a particular WMI namespace. This portion of the script is shown here.<\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Function Get-WmiClassProperties<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">{ <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Param(<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">[string]$namespace = &#8220;root\\cimv2&#8221;,<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">[string]$computer = &#8220;.&#8221;<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">)<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">$abstract = $false<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">$property = $null<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">$classes = Get-WmiObject -List -Namespace $namespace<\/span><\/p>\n<\/blockquote>\n<p>Next, the function uses the <i>Foreach<\/i> keyword to walk through the collection of classes. It checks the class qualifiers collection to see if one of the qualifiers is <b>abstract<\/b>. If a WMI class is an abstract, it should not be queried directly. This portion of the script is shown here.<\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Foreach($class in $classes)<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">{<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Foreach($q in $class.Qualifiers)<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">{ if ($q.name -eq &#8216;Abstract&#8217;) {$abstract = $true} }<\/span><\/p>\n<\/blockquote>\n<p>After a WMI class is determined to not be an <b>abstract<\/b> class, the properties collection of the WMI class is retrieved, and each of the properties qualifiers are examined to see if the <i>write<\/i> qualifier appears. This portion of the script is shown here.<\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">If(!$abstract) <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">{ <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Foreach($p in $class.Properties)<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">{ <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Foreach($q in $p.qualifiers) <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">{ <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">if($q.name -match &#8220;write&#8221;)<\/span><\/p>\n<\/blockquote>\n<p>I add each writable property name to the <b>$property<\/b> variable, and add a return and a new line character at the end of each property name. Next I call the <b>New-Underline<\/b> function to underline the name of WMI classes that have at least one writable WMI property. After that I list each writable property under the name of the WMI class, reinitialize a couple of variables, end the function, and call the script. This portion of the script is shown here.<\/p>\n<blockquote>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">{ <\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">$property += $p.name + &#8220;`r`n&#8221;<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">} #end if name<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">} #end foreach q<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">} #end foreach p<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">if($property) {New-Underline $class.name}<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">$property<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">} #end if not abstract<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">$abstract = $false<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">$property = $null<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">} #end foreach class<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">} #end function Get-WmiClassProperties<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\"># *** Entry Point to Script ***<\/span><\/p>\n<p><span style=\"font-family: Lucida Sans Typewriter;font-size: x-small\">Get-WmiClassProperties<\/span><\/p>\n<\/blockquote>\n<p>When the script run, it produces a listing similar to the one in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3678.HSG-3-11-11-03_61DC981B.jpg\"><img decoding=\"async\" height=\"442\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6305.HSG-3-11-11-03_thumb_316613A5.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\" \/><\/a><\/p>\n<p>JE, that is all there is to finding WMI class properties that can actually do things. I invite you to join me tomorrow for the <a target=\"_blank\" href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/tags\/weekend+scripter\/\">Weekend Scripter<\/a>, when I will begin to make a couple of improvements to these exploratory scripts&mdash;it will be cool!<\/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><span style=\"font-family: Segoe UI;font-size: x-small\">Ed Wilson, Microsoft Scripting Guy<\/span><\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn how to use Windows PowerShell to find WMI classes that allow you to change property values. &nbsp; Hey Scripting Guy! I recently saw a Windows PowerShell script that looked like it actually changed the value of a property. I know that Windows PowerShell methods require you to put things in parentheses, and this [&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-15351","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 allow you to change property values. &nbsp; Hey Scripting Guy! I recently saw a Windows PowerShell script that looked like it actually changed the value of a property. I know that Windows PowerShell methods require you to put things in parentheses, and this [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/15351","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=15351"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/15351\/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=15351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=15351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=15351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}