I am trying to run the IsActivated, IsEnabled and IsOwned methods from the Win32_Tpm WMI class in C#.
For testing purposes, I have created a console application with the following code:
ManagementScope managementScope = new ManagementScope(@"ROOT\CIMV2\Security\MicrosoftTpm");
ManagementPath managementPath = new ManagementPath("Win32_Tpm");
ManagementClass managementClass = new ManagementClass(managementScope, managementPath, null);
managementClass.InvokeMethod("IsActivated", null);
InvokeMethod throws "Invalid method Parameter(s)"
The IsActivated method signature does not mention any input parameter:
uint32 IsActivated(
[out] boolean IsActivated
);
To confirm this, I ran:
managementClass.GetMethodParameters("IsActivated");
Which returned:
System.Management.ManagementObject.GetMethodParameters returned null
Visual Studio is launched with run as Admin and the app.manifest was configured to require Administrator privileges:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
The methods should definitely work, as showcased in WMI Explorer, but I am struggling to understand what I am doing wrong.