|
Question : Remove/Delete computer account from windows 2000 domain using command line tool
|
|
Im trying to find a command line solution to remove a computer account from a windows 2000 domain.
The command will run from the computer being removed.
NETDOM appears to simply disable the account and not remove it. This is a problem when the original account is in OU1 and I try to add it back to OU2.
Further Details:
The computer will be ghosted with a XP image. The computer name will be reassigned as previous however the domain account has not been deleted. A post image script after the ghost image will attempt to remove any previous accounts then add the machine back. If the computer account is located in any other organization unit other than the target the join will fail.
Thanks.
|
Answer : Remove/Delete computer account from windows 2000 domain using command line tool
|
|
OK then - try this, as it uses the WINT: method of access (versus LDAP), it should care about which OU the computer is in.
' **************************************************************************** ' This script removes a computer from a domain ' **************************************************************************** ' Goto http://www.activxperts.com/activmonitor and click on ADSI Samples ' for more samples ' ****************************************************************************
Sub RemoveComputer ( strDomain, strComputer ) Dim objDC Set objDC = getobject("WinNT://" & strDomain ) objDC.Delete "Computer", strComputer End Sub
' **************************************************************************** ' Main ' **************************************************************************** Dim strDomain, strComputer Do strDomain = inputbox( "Please enter a domainname", "Input" ) Loop until strDomain <> "" Do strComputer = inputbox( "Please the name of the computer to be removed from the domain",
"Input" ) Loop until strComputer <> "" RemoveComputer strDomain, strComputer WScript.Echo "Done."
|
|
|
|