I have been asked about discovering the methods available on a WMI object. I’ve mentioned the GetMethodParameters method a few times but it can be difficult to find. Normally if we want to discover the methods on an object we would do this
Get-WmiObject Win32_Service | Get-Member -MemberType method
which gives this list
Change
ChangeStartMode
Delete
GetSecurityDescriptor
InterrogateService
PauseService
ResumeService
SetSecurityDescriptor
StartService
StopService
UserControlService
we will ignore the terminal services object that also appears
To dig into the underlying object we use .psbase (or Get-Member -MemberType method –View base)
(Get-WmiObject Win32_Service).psbase | Get-Member -MemberType method
gives us this list
Address
Clone
CopyTo
Equals
Get
GetEnumerator
GetHashCode
GetLength
GetLongLength
GetLowerBound
GetType
GetUpperBound
GetValue
Initialize
Set
SetValue
ToString
Note that the object type is System.Management.Automation.PSMemberSet
When we use Get-WmiObject we are looking at an instance of the WMI class. To look at the class itself
[wmiclass]"Win32_Service" | Get-Member -MemberType method
but this just shows a Create method
If we drop into the base object now
([wmiclass]"Win32_Service").psbase | Get-Member -MemberType method
we get
Clone
CompareTo
CopyTo
CreateInstance
CreateObjRef
Delete
Derive
Dispose
Equals
Get
GetHashCode
GetInstances
GetLifetimeService
GetMethodParameters
GetPropertyQualifierValue
GetPropertyValue
GetQualifierValue
GetRelated
GetRelatedClasses
GetRelationshipClasses
GetRelationships
GetStronglyTypedClassCode
GetSubclasses
GetText
GetType
InitializeLifetimeService
InvokeMethod
Put
SetPropertyQualifierValue
SetPropertyValue
SetQualifierValue
ToString
Which shows the Method we want and a few other potentially interesting methods to test out.