fly Posted June 8, 2005 Posted June 8, 2005 (edited) I'm using the following code to remove a computer account from a domain:Dim strSerialNumberstrSerialNumber="PC1234"Set objCont = GetObject("WinNT://" & "domain.com")objCont.Delete "Computer", strSerialNumberand can't get it to work. However, this does work:Set objCont = GetObject("WinNT://" & "domain.com")objCont.Delete "Computer", "PC1234"What gives?Background and extra credit question for cash: PCs here get reimaged many times, but keep the same computer name. So I'm trying to get sysprep to pull the Dell Asset tag and use that to join the domain. I got all that working, but the joining of the domain fails if the computer account is already there, so I'm using the above script to try and delete it. Sadly, this is taking me 3+ VBScripts to complete this task, because I suck. If you have any ideas how to make this all one script, I will love you forever and paypal you some cash. Thanks. Edited July 1, 2005 by fly
Martin Zugec Posted June 17, 2005 Posted June 17, 2005 Hello Fly!First of all: leave imaging and begin with scripting solutions (unattended). It will save you lot of time + problemsTo your problem:This is what I found in my DBDim strDomain : strDomain = "domain.com"Dim strComputerstrComputer = InputBox( "Please the name of the computer to be removed from the domain", "Input" )RemoveComputer strDomain, strComputerSub RemoveComputer( strDomain, strComputer ) Dim objDC Set objDC = getobject("WinNT://" & strDomain ) objDC.Delete( "Computer", strComputer )End SubHowever you should use ONE script, that will check if there is computer account and it will call function funcRemoveComputer... Please send me PM next week, I will write it for you
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now