/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" Wmi-Help Part 1 "," Create System Variable From MSH (Part2) "," Create System Variable From MSH "," Setting the Path / system variables from MSH "," Obfuscated Monad Script "," Get Binary SID in MSH (Share Security Update) "," Replace Security on existing share using MSH "," Einstein "," Runas with loading Profile script in MSH "," do the MSH - CMD- MSH loop. & RunAs in MSH "," ")

Saturday, November 05, 2005

 


WMI help Part 2



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




Comments: Post a Comment

Links to this post:

Create a Link



<< Home

Archives

October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Google
 
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?