Why I have WMI Class but no instance?

0

I am following Microsoft guide on how to setup my own WMI provider. After registering my provider with Register-CimProvider.exe I can see the class: Get-CimClass -Namespace root/StandardCimv2/sample -ClassName MSFT_WindowsProcess

   NameSpace: ROOT/StandardCimv2/sample

CimClassName                        CimClassMethods      CimClassProperties
------------                        ---------------      ------------------
MSFT_WindowsProcess                 {RequestStateChan... {Caption, Description, ElementName, InstanceID...}

However, there is no instance of this class as the next command fails:

Get-CimInstance -ClassName MSFT_WindowsProcess -Namespace root/StandardCimv2/sample
Get-CimInstance : Provider load failure
At line:1 char:1
+ Get-CimInstance -ClassName MSFT_WindowsProcess -Namespace root/Standa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (root/StandardCi..._WindowsProcess:String) [Get-CimInstance], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041013,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand

This is my mof:

#pragma include ("cim_schema_2.26.0.mof")
#pragma include ("MSFT_Qualifiers.mof")

// MSFT_WindowsProcess class derives from CIM_Process class,
// which defines the schema for the processes running on windows OS.
[ClassVersion("1.0.0")]
class MSFT_WindowsProcess : CIM_Process
{
 string CommandLine;

 [Description("This instance method demonstrates modifying the "
  "priority of a given process."
  "The method returns an integer value of 0 if the "
  "operation was successfully completed,"
  "and any other number to indicate an win32 error code.")]
 uint32 SetPriority([In] uint32 Priority);

 [static,
 Description("This static method demonstrates creating a process "
  "by supplying commandline to start a new process."
  "It will output the reference to the newly created process."
  "The method returns an integer value of 0 if the process "
  "was successfully created, and any other number to "
  "indicate an win32 error code.")]
 uint32 Create([In] string CommandLine, [Out] CIM_Process ref Process);
};

I followed every other step in the guide.

What I need to do to create an instance of the class?

wmi
asked on Stack Overflow Jul 9, 2020 by Draif Kroneg

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0