fly Posted June 8, 2005 Share 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 Link to comment Share on other sites More sharing options...
fly Posted June 17, 2005 Author Share Posted June 17, 2005 anyone? Link to comment Share on other sites More sharing options...
Martin Zugec Posted June 17, 2005 Share 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 Link to comment Share on other sites More sharing options...
fly Posted June 22, 2005 Author Share Posted June 22, 2005 Thanks! PM sent. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now