Jump to content

Recommended Posts

Posted (edited)

I'm using the following code to remove a computer account from a domain:

Dim strSerialNumber
strSerialNumber="PC1234"
Set objCont = GetObject("WinNT://" & "domain.com")
objCont.Delete "Computer", strSerialNumber

and 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 by fly
  • 2 weeks later...

Posted

Hello Fly!

First of all: leave imaging and begin with scripting solutions (unattended). It will save you lot of time + problems

To your problem:

This is what I found in my DB

Dim strDomain : strDomain = "domain.com"
Dim strComputer

strComputer = InputBox( "Please the name of the computer to be removed from the domain", "Input" )
RemoveComputer strDomain, strComputer

Sub RemoveComputer( strDomain, strComputer )
   Dim objDC
   Set objDC = getobject("WinNT://" & strDomain )
   objDC.Delete( "Computer", strComputer )
End Sub

However 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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...