Radimus, I'm trying to use your code below, but I am getting a return value of 87, which indicates "The parameter is incorrect". I'm puzzled, because if I change the password variable, my return value becomes 1326, which is "Logon failure: unknown username or bad password", as one would expect. This seems to indicate to me that the syntax is correct.

Am I missing something? I'm a NOOB at this, so forgive me if I'm overlooking something simple.

 Code:
$ou = 'OU=MySubOu,OU=MyOU,DC=MyDomain,DC=com'
$user = MyUser
$password = MyPassword
$objNetwork = CreateObject("WScript.Network")
$strComputer = $objNetwork.ComputerName
$objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2:Win32_ComputerSystem.Name='"+@wksta+"'")
$ReturnValue = $objComputer.JoinDomainOrWorkGroup("MyDomain.com", $password, "MyDomain\"+$user, $OU, 35)
If $ReturnValue
	? "Failed joining "+@WKSTA+" to domain"
	? "ReturnValue = " + $ReturnValue
		GoTo END
EndIf


Edited by Mart (2011-01-28 09:02 AM)
Edit Reason: Please use code tags when posting code.