Discussion:
WMI 'Invalid Method Parameter(s)' JoinDomainOrWorkGroup
(too old to reply)
Jacob Dixon
2009-12-16 13:59:01 UTC
Permalink
I am at a lost. I have verified what I am doing against the documentation on
microsofts website:
http://msdn.microsoft.com/en-us/library/aa392154(VS.85).aspx[^] and I just
can't figure out why it would give me this error.


My Connection object is not shown as it is global within the class I have it
in. I am connect to this machine that is not on the domain and get installed
applications, all services, and computer information. The problem is it keeps
throwing a "Invalid Method Parameter(s)" error.

In case your wondering.. I ran a foreach look on the inParams.Properties and
verified that all the method parameters existed in the inParams (which it
does).

Any help would be great!


public string Join(string dns, string domain, string username, string
password) {
try
{
ManagementScope scope = new ManagementScope(@"\\" + dns + @"\root\CIMV2",
conn);
ManagementPath path = new ManagementPath("Win32_ComputerSystem");

ManagementClass mgmtClass = new ManagementClass(scope, path, null);
ManagementBaseObject inParams =
mgmtClass.GetMethodParameters("JoinDomainOrWorkgroup");

inParams["Name"] = domain;
inParams["UserName"] = username;
inParams["Password"] = password;
inParams["AccountOU"] = null;
inParams["FJoinOptions"] = (UInt32)1;

ManagementBaseObject outParams =
mgmtClass.InvokeMethod("JoinDomainOrWorkgroup", inParams, null);
string status = ReturnedValue.JoinDomainOrWorkgroup(Convert.ToInt

32(outParams["ReturnValue"]));
return status;
}
catch (Exception ex)
{
EventLog.WriteEntry("ADEM Application", ex.Message,
EventLogEntryType.Error);
return ex.Message;
}
}
Jacob Dixon
2009-12-17 17:58:01 UTC
Permalink
Anyone? I have treid the WMI Code Creator for doing this on a remote computer
and it still fails!
Post by Jacob Dixon
I am at a lost. I have verified what I am doing against the documentation on
http://msdn.microsoft.com/en-us/library/aa392154(VS.85).aspx[^] and I just
can't figure out why it would give me this error.
My Connection object is not shown as it is global within the class I have it
in. I am connect to this machine that is not on the domain and get installed
applications, all services, and computer information. The problem is it keeps
throwing a "Invalid Method Parameter(s)" error.
In case your wondering.. I ran a foreach look on the inParams.Properties and
verified that all the method parameters existed in the inParams (which it
does).
Any help would be great!
public string Join(string dns, string domain, string username, string
password) {
try
{
conn);
ManagementPath path = new ManagementPath("Win32_ComputerSystem");
ManagementClass mgmtClass = new ManagementClass(scope, path, null);
ManagementBaseObject inParams =
mgmtClass.GetMethodParameters("JoinDomainOrWorkgroup");
inParams["Name"] = domain;
inParams["UserName"] = username;
inParams["Password"] = password;
inParams["AccountOU"] = null;
inParams["FJoinOptions"] = (UInt32)1;
ManagementBaseObject outParams =
mgmtClass.InvokeMethod("JoinDomainOrWorkgroup", inParams, null);
string status = ReturnedValue.JoinDomainOrWorkgroup(Convert.ToInt
32(outParams["ReturnValue"]));
return status;
}
catch (Exception ex)
{
EventLog.WriteEntry("ADEM Application", ex.Message,
EventLogEntryType.Error);
return ex.Message;
}
}
Loading...