wmi - Invalid method parameters when trying to call RequestRefresh from C# to SCCM server -
i'm trying phone call requestrefresh function against sms_collection anytime new device added sccm through our application. when phone call execute next exception.
main: unrecoverable service error.|system.management.managementexception invalid method parameter(s) @ system.management.managementexception.throwwithextendedinfo(managementstatus errorcode) @ system.management.managementobject.invokemethod(string methodname, managementbaseobject inparameters, invokemethodoptions options) @ sccmproxy.adapter.refreshcollection(string collectionname) in c:\ws\development\sccmagent\main\sccmproxy\sccmproxy\adapter.cs:line 733 @ sccmproxy.testhelper.executetest(proxyconfiguration config) in c:\ws\development\sccmagent\main\sccmproxy\sccmproxy\testhelper.cs:line 144 @ sccmproxy.service.main() in c:\ws\development\sccmagent\main\sccmproxy\sccmproxy\service.cs:line 134 void throwwithextendedinfo(system.management.managementstatus)
here code
managementpath pathmethod = new managementpath("sms_collection"); using (managementclass processclass = new managementclass(this.configuration.newtargetscope, pathmethod, null)) { managementbaseobject inparams = processclass.getmethodparameters("requestrefresh"); using (managementbaseobject outparams = processclass.invokemethod("requestrefresh", inparams, null)) { logger.info(methodbase.getcurrentmethod().name, "successful collection refresh: {0}", outparams["returnvalue"]); } }
the problem when phone call getmethodparameters returns object parameter called "includesubcollections" valid 2007 sccm i'm using 2012 sccm , requestrefresh method doesn't utilize parameter anymore. how getmethodcall returning old function parameter when have pointing new 2012 sccm instance?
i couldn't above code work able phone call requestrefresh via wql using illustration http://msdn.microsoft.com/en-us/library/hh949402.aspx
public void refreshcollection(wqlconnectionmanager connection, string collectionid) { iresultobject collection = connection.getinstance(string.format("sms_collection.collectionid='{0}'", collectionid)); collection.executemethod("requestrefresh", null); }
c# wmi sccm
No comments:
Post a Comment