XyberSchwifty
XyberSchwifty
CC#
Created by XyberSchwifty on 6/6/2023 in #help
❔ CIM Class MDM_RemoteWipe Method Question
Hi friends, I am attempting to call a method using CimSession.InvokeMethod() called doWipeProtectedMethod. Microsoft does not seem to provide a lot of documentation on this, so I am confused about the parameters that are supposed to be used with it. Here's the Microsoft Doc and my current code: https://learn.microsoft.com/en-us/windows/win32/dmwmibridgeprov/mdm-remotewipe-dowipeprotectedmethod https://learn.microsoft.com/en-us/dotnet/api/microsoft.management.infrastructure.cimmethodparameter.create?view=powershellsdk-7.3.0
Microsoft.Management.Infrastructure.CimSession session = CimSession.Create("localhost");

var wipeMethodParamCollect = new CimMethodParametersCollection() {
Microsoft.Management.Infrastructure.CimMethodParameter.Create("param", "", Microsoft.Management.Infrastructure.CimType.String, CimFlags.In)
};

session.InvokeMethod("root\\cimv2\\mdm\\dmmap", "MDM_RemoteWipe", "doWipeProtectedMethod", wipeMethodParamCollect);
Microsoft.Management.Infrastructure.CimSession session = CimSession.Create("localhost");

var wipeMethodParamCollect = new CimMethodParametersCollection() {
Microsoft.Management.Infrastructure.CimMethodParameter.Create("param", "", Microsoft.Management.Infrastructure.CimType.String, CimFlags.In)
};

session.InvokeMethod("root\\cimv2\\mdm\\dmmap", "MDM_RemoteWipe", "doWipeProtectedMethod", wipeMethodParamCollect);
I am not understanding what to do with the "Object" parameter of the CimMethodParamater.Create() method. Also, if what I'm doing seems correct, then I don't understand why my session.InvokeMethod() fails. I get the following .NET application error:
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.Management.Infrastructure.CimException
   at Microsoft.Management.Infrastructure.Internal.Operations.CimSyncEnumeratorBase`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
   at System.Linq.Enumerable.SingleOrDefault[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>)
   at Microsoft.Management.Infrastructure.CimSession.InvokeMethod(System.String, System.String, System.String, Microsoft.Management.Infrastructure.CimMethodParametersCollection, Microsoft.Management.Infrastructure.Options.CimOperationOptions)
 
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.Management.Infrastructure.CimException
   at Microsoft.Management.Infrastructure.Internal.Operations.CimSyncEnumeratorBase`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
   at System.Linq.Enumerable.SingleOrDefault[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>)
   at Microsoft.Management.Infrastructure.CimSession.InvokeMethod(System.String, System.String, System.String, Microsoft.Management.Infrastructure.CimMethodParametersCollection, Microsoft.Management.Infrastructure.Options.CimOperationOptions)
 
4 replies