/build/static/layout/Breadcrumb_cap_w.png

Join Domain VBS script - any way to remove PC before joining?

Here is our VBS script that we use to join the domain. Is there a way to have it delete the PC if it already exists? That's the problem we're running into. Any help here??

https://dl.dropbox.com/u/119117/kace/test.vbs

 

Code:

 Const JOIN_DOMAIN = 1

Const ACCT_CREATE = 2

 

strDomain = "CUSD200.LOCAL"

strUser = "PCTECH"

strPassword = "XXX"

strOU = "ou=distwidelaptops,ou=d200computers,DC=CUSD200,DC=local"

 

Set objNetwork = CreateObject("WScript.Network")

strComputer = objNetwork.ComputerName

 

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

 

objComputer.JoinDomainOrWorkGroup strDomain, strPassword, strDomain & "\" & strUser, strOU, JOIN_DOMAIN + ACCT_CREATE
 
 
 
 
 
 

 

 


0 Comments   [ + ] Show comments

Answers (1)

Posted by: jagadeish 11 years ago
Red Belt
1

Check with below code..


Comments:
  • Where do I add this? At the end of the script? Beginning? And this 1 line should delete it? - sfigg 11 years ago
  • (for some reason I don't think the code fully shows up) - sfigg 11 years ago
    • Sorry we are working to address this problem right now, your code should appear as expected shortly. - bkelly 11 years ago
  • Thanks Bob... - jagadeish 11 years ago
  • Actually...I'm stupid. I just thought that this won't work. We want to be able to delete the PC from the domain (I'm assuming it runs off the pc name). However, upon imaging, and reboot - it will sysprep, and apply a random PC name - so we don't want to remove that from the domain - we want to remove the pc name that was on there before sysprep. Not sure how to do this - I heard ADSI scripts in KBE would work, but I don't know the first thing about that. - sfigg 11 years ago
  • If I try to run this as a preinstall task in KBE, it says that the specified domain either does not exist or could not be contacted - hmmm. ADSI is suppose to allow us to talk to AD I thought. - sfigg 11 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ