This blog has moved to http://ThePowerShellGuy.com
Greetings /\/\o\/\/
w.b.
As in the first part :
Wmi-Help Part 1 we got all the WMI classes and there description back, we are now looking deeper into a Single Class.
This time I implemented it as a fuction, as Im not planning to save this info or act upon it.
its just for reference. This stay's a loose function in the "WMI Help system"
let's Look at the parts again :
The Parm / If / Throw block will force you to give a WMI class
Then we have to set the get Amended Qualfiers again, as we are (very) interested in the descriptions again.
this Time we will put the $opt into the constructor of the ManagementObject directly.
(Notice I'm using the system.management.ManagementClass object here, not the system.management.ManagementObject, thats because I like the Overload Better ;-))the rest of the script is pretty clear I think if you did read that last first part, I'm just outputting all the data there.
Ad the End of the script I set the GWH alias to give Quick acces from the MSH commandline for this function.
Now where all done, for this part,
just load the script, ...try this ...,
MSH>gwh win32_share
... and be amazed ;-)
in the next part we will dive deeper into the Methods , and get even more help (Descriptions) there
gr /\/\o\/\/
PS. Try this also together with previous handy (GUI) tools for Exploring WMI
See
WMI viewer script for MSH (GUI) ,
MSH Object Viewer ,
and for help on building Difficult Queries :
Lets Query WMI from MSH then I think you can already get alot of info from MSH about WMI at this point next to the get-Member Command.
Ok, and finaly the script :
# GetWmiClasInfo.MSH
# Gets Property and Method with descriptions from WMI class
# /\/\o\/\/ 2005
Function get-WMIHelp{
Param ([string] $WmiClass = "")
if ($wmiClass -eq "") {Throw "No WMIClass given"}
# Set Options
$opt = new-object system.management.ObjectGetOptions
$opt.UseAmendedQualifiers = $true
$MO = new-object system.management.ManagementClass($WmiClass,$opt)
"`n$WMIClass :"
$MO.get_Qualifiers()["description"].value
"`n$WmiClass Properties :`n"
$MO.get_properties()| foreach {
"$($_.Name) :"
$_.get_Qualifiers()["description"].value
""
}
"$WmiClass Methods :`n"
$MO.get_Methods() | foreach {
"$($_.Name) :"
$_.get_Qualifiers()["description"].value
""
}
}
set-alias gwh get-WMIHelp