Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WMI 'Invalid Method Parameter(s)' JoinDomainOrWorkGroup

55 views
Skip to first unread message

Dixon@discussions.microsoft.com Jacob Dixon

unread,
Dec 16, 2009, 8:59:01 AM12/16/09
to
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

unread,
Dec 17, 2009, 12:58:01 PM12/17/09
to
Anyone? I have treid the WMI Code Creator for doing this on a remote computer
and it still fails!
0 new messages