
Removing Computer Accounts from NT Domain (with Static Names)
Basically 2 lines of code remove computer from the domain (You will need
ADSI v2.5 on the PC you are running script from):
Set objCont = GetObject("WinNT://" & "Domain_Name")
objCont.Delete "Computer", "PC_Name"
You can prepare 3 different list files with computer names and then run them
against the script below.
I wrote this on the fly (could be improved)
----------------------------------
'** File: rempc.vbs
'** Syntax: rempc.vbs [ListFile]
Dim targetDomain, fso, oArgs, inputFile
Dim objCont, pcList, openList, arrayList, x
On Error Resume Next
'** Change to reflect Domain
targetDomain = "Your_Domain"
Set fso = CreateObject("Scripting.FileSystemObject")
Set oArgs = Wscript.Arguments
If oArgs.Count <> 1 Then NoArgs
inputFile = oArgs(0)
Set openList = fso.OpenTextFile(inputFile, 1, False)
If Err.Number <> 0 then msgbox "Can not Open specified File" : Wscript.Quit
pcList = openList.ReadAll
arrayList = Split(pcList, VbCrLf)
openList.Close
Set objCont = GetObject("WinNT://" & targetDomain)
ret = objCont.Name
If Err.Number <> 0 then msgbox "Domain is not available." : Wscript.Quit
For x = 0 to UBound(arrayList)
If Not arrayList(x) = "" then objCont.Delete "Computer", arrayList(x)
Next
pcList = Nothing
arrayList = Nothing
Sub NoArgs()
msgbox "Syntax: rempc.vbs [list_file] - List File should contain 1 pc
name per line."
Wscript.Quit
End Sub
-------------------------------------
--
Gurgen Alaverdian
http://www.gurgensvbstuff.com
Quote:
> I need to remove blocks of 12 computers from our NT domain (not AD). The
> names of the machines are always the same, but as they are part of a lab
> environment, they are constantly being rebuilt. Sysprep readds them to
the
> domain as it runs, but I need to remove them first.
> I need three separate scripts, be all would be based off the same script,
> just ran according to what I was testing on that specific day (laptops,
> desktops, workstations).
> Any idears?
> CJ