List of WMI Method Attributes

167 views Asked by At

I try to access all attributes of the given method from any classes into the WMI.

For example, I can list the methods inside "Win32_SystemDriver " class

Get-WmiObject -Class Win32_SystemDriver -List | Select -ExpandProperty Methods

Name               InParameters                           OutParameters                          Origin            Qualifiers
----               ------------                           -------------                          ------            ----------
StartService                                              System.Management.ManagementBaseObject CIM_Service       {MappingStrings, Override, ValueMap}
StopService                                               System.Management.ManagementBaseObject CIM_Service       {MappingStrings, Override, ValueMap}
PauseService                                              System.Management.ManagementBaseObject Win32_BaseService {MappingStrings, ValueMap}
ResumeService                                             System.Management.ManagementBaseObject Win32_BaseService {MappingStrings, ValueMap}
InterrogateService                                        System.Management.ManagementBaseObject Win32_BaseService {MappingStrings, ValueMap}
UserControlService System.Management.ManagementBaseObject System.Management.ManagementBaseObject Win32_BaseService {MappingStrings, ValueMap}
Create             System.Management.ManagementBaseObject System.Management.ManagementBaseObject Win32_BaseService {MappingStrings, Static, ValueMap}
Change             System.Management.ManagementBaseObject System.Management.ManagementBaseObject Win32_BaseService {MappingStrings, ValueMap}
ChangeStartMode    System.Management.ManagementBaseObject System.Management.ManagementBaseObject Win32_BaseService {MappingStrings, ValueMap}
Delete                                                    System.Management.ManagementBaseObject Win32_BaseService {MappingStrings, ValueMap}

In MSDN document, Create method of the Win32_SystemDriver class has many attributes like;

uint32 Create(
  [in] string  Name,
  [in] string  DisplayName,
  [in] string  PathName,
  [in] uint8   ServiceType,
  [in] uint8   ErrorControl,
  [in] string  StartMode,
  [in] boolean DesktopInteract,
  [in] string  StartName,
  [in] string  StartPassword,
  [in] string  LoadOrderGroup,
  [in] string  LoadOrderGroupDependencies[],
  [in] string  ServiceDependencies[]
);

Can I see these properties with CIM/WMI cmdlets? Also, if it is possible I want to see with their descriptions.

1

There are 1 answers

1
jeremywat On BEST ANSWER

What you call "attributes" are parameters that are passed to the Create() method. Those parameters are displayed in the Definition property of the Create() member if you run Get-Member:

Get-WmiObject -Class Win32_SystemDriver -List | Get-Member Create | Format-List

TypeName   : System.Management.ManagementClass#ROOT\cimv2\Win32_SystemDriver
Name       : Create
MemberType : Method
Definition : System.Management.ManagementBaseObject Create(System.String Name, System.String DisplayName,
             System.String PathName, System.Byte ServiceType, System.Byte ErrorControl, System.String StartMode,
             System.Boolean DesktopInteract, System.String StartName, System.String StartPassword, System.String
             LoadOrderGroup, System.String[] LoadOrderGroupDependencies, System.String[] ServiceDependencies

If you want it as a list we can use Doug's Regex pattern:

PS > (Get-WmiObject -Class Win32_SystemDriver -List | Get-Member Create).Definition -replace '^.+\(|\)$' -split ',\s?'

System.String Name
System.String DisplayName
System.String PathName
System.Byte ServiceType
System.Byte ErrorControl
System.String StartMode
System.Boolean DesktopInteract
System.String StartName
System.String StartPassword
System.String LoadOrderGroup
System.String[] LoadOrderGroupDependencies
System.String[] ServiceDependencies

With some more parsing we can turn these into more readable/usable objects:

PS > (Get-WmiObject -Class Win32_SystemDriver -List | Get-Member Create).Definition -replace '^.+\(|\)$' -split ',\s?' | ForEach-Object {
   $split = $_.Split()
   [PSCustomObject]@{
      Parameter = $split[1]
      Type = [type]$split[0]
   }
}

Parameter                  Type
---------                  ----
Name                       System.String
DisplayName                System.String
PathName                   System.String
ServiceType                System.Byte
ErrorControl               System.Byte
StartMode                  System.String
DesktopInteract            System.Boolean
StartName                  System.String
StartPassword              System.String
LoadOrderGroup             System.String
LoadOrderGroupDependencies System.String[]
ServiceDependencies        System.String[]

We also converted the Type strings to [System.Type] objects.