jadewith
(Fresh Scripter)
2009-07-24 03:56 PM
Join domain VBS Conversion

Hi everyone,

I am in the process of migrating from a poorly put together Novell 5.1 Domain to an 2003 AD domain. I'm rying to convert the following VB script to KiXtart and am having a little trouble. I have run Sanity against My conversion and do not receive anything but the time. When I run the script in KiXtart I receive the error

 Quote:
ERROR: expected ')'!
Line: 39



My script:
 Code:
 DIM $JOIN_DOMAIN
DIM $ACCT_CREATE
DIM $ACCT_DELETE
DIM $WIN9X_UPGRADE
DIM $DOMAIN_JOIN_IF_JOINED
DIM $JOIN_UNSECURE
DIM $MACHINE_PASSWORD_PASSED
DIM $DEFERRED_SPN_SET
DIM $INSTALL_INVOCATION
DIM $strDomain
DIM $strPassword
DIM $strUser
DIM $objNetwork
DIM $strComputer
DIM $objComputer
DIM $rc


$JOIN_DOMAIN = 1
$ACCT_CREATE = 2
$ACCT_DELETE = 4
$WIN9X_UPGRADE = 16
$DOMAIN_JOIN_IF_JOINED = 32
$JOIN_UNSECURE = 64
$MACHINE_PASSWORD_PASSED = 128
$DEFERRED_SPN_SET = 256
$INSTALL_INVOCATION = 262144

$strDomain = "Bandcamp.local"
$strPassword = "Flute"
$strUser = "Say my Name!"

$objNetwork = CreateObject("WScript.Network")
$strComputer = $objNetwork.ComputerName


$objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!//$strComputer")

$rc=$objComputer.JoinDomainOrWorkGroup($strDomain,$strPassword, $strUser, '', $JOIN_DOMAIN + $ACCT_CREATE) 


Original VBS:
 Code:
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144

strDomain = "Cnail.com"
strPassword = "hicane"
strUser = "jdewith"

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
   strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
       strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
   strPassword, strDomain & "\" & strUser, NULL, _
       JOIN_DOMAIN + ACCT_CREATE) 


You help, as always, is appreciated,
Jason


AllenAdministrator
(KiX Supporter)
2009-07-24 04:23 PM
Re: Join domain VBS Conversion

I've looked over your script... and I've run out of time. I did a board search on JoinDomainOrWorkGroup and it pulled up a couple of threads which it appeared to be working. I did see Null was defined as "NULL" in one thread, and tried it but got the same error as you. Maybe they will give you some direction.

jadewith
(Fresh Scripter)
2009-07-24 04:25 PM
Re: Join domain VBS Conversion

Thanks Allen,

I'll take a look


jadewith
(Fresh Scripter)
2009-07-24 05:27 PM
Re: Join domain VBS Conversion

Got it here

http://www.kixtart.org/forums/ubbthreads.php?ubb=showthreaded&Number=176628

Thanks again Allen


AllenAdministrator
(KiX Supporter)
2009-07-24 11:52 PM
Re: Join domain VBS Conversion

I see now in your VBS to Kix conversion, this line is different.

 Quote:
$objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!//" + $strComputer)


This code is dang near exactly the same as the linked one... Apronk must have gotten his from the same source. \:\)


Radimus
(KiX Supporter)
2009-07-25 02:51 PM
Re: Join domain VBS Conversion

I have a joindomain tool as well based somewhat from the above code.

I have recently been granted a "service acct" for joining computers and our naming convention has been changed to serno = @wksta, I can "automate" it...

I have an IP subnet detection feature to select the default OU and am also making a GPO to run the script on all PCs in the default "Computers" container... for the lazy IT staff that don't put the PCs into the correct OUs.


NTDOCAdministrator
(KiX Master)
2009-07-27 11:10 PM
Re: Join domain VBS Conversion

What a step back in time. I never did write an update for the KiXforms JoinAD script as I ended up never really needing to do it much after that.

Arend_
(MM club member)
2009-07-28 08:21 AM
Re: Join domain VBS Conversion

I remember writing one for you doc, just to get you off that NETDOM tool ;-) Was something with a KixForms GUI you've written for NETDOM and I rewrote it with builtin code. Can't find the post though...

[edit]
Found it
[/edit]


NTDOCAdministrator
(KiX Master)
2009-07-29 08:32 PM
Re: Join domain VBS Conversion

Yeah, thanks but that's what I mean. I never did get around to doing it because after that main big push I didn't need to use it much anymore.

As is often the case, got busy with other things and never did get back to it.


Radimus
(KiX Supporter)
2009-07-29 09:28 PM
Re: Join domain VBS Conversion

I just wrote a new version of my old code and it works fine for about 90% of my machines... but some of them cough up error 1219

 Code:

	$newname = 'NewName'

	$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2")
	$colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
	For Each $objComputer in $colComputers
		$err = $objComputer.Rename($NewName, $password, $user)
		If $err
			 $nul = sendmessage(@wksta, "Failed Renaming "+@wksta+" to "+$NewName + @crlf + $err)
		else
			$nul = sendmessage(@wksta, "Updates to this PC require the computer to reboot. Please reboot at your earliest convenience.")
		endif
	Next