Removing Computer Accounts from NT Domain (with Static Names) 
Author Message
 Removing Computer Accounts from NT Domain (with Static Names)

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



Wed, 15 Dec 2004 01:40:15 GMT  
 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



Wed, 15 Dec 2004 05:49:18 GMT  
 Removing Computer Accounts from NT Domain (with Static Names)
You mention ADSI v2.5. Is this script for Active Directory? I need one for a
straight NT Domain. We are moving in the AD direction, but my lab will
remain connected to an NT DC for quite a while. BTW: Nice website!

CJ



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



Thu, 16 Dec 2004 01:25:27 GMT  
 Removing Computer Accounts from NT Domain (with Static Names)
:: You mention ADSI v2.5. Is this script for Active Directory? I need
:: one for a straight NT Domain. We are moving in the AD direction, but
:: my lab will remain connected to an NT DC for quite a while. BTW: Nice website!
::

ADSI works fine for NT domains using the WinNT provider...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Thu, 16 Dec 2004 02:40:12 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. remove computer from NT Domain

2. AD Error when removing computer accounts via script.

3. Adding computer account to w2k domain

4. Computer Accounts in New Domain

5. create user account in an NT-DOMAIN

6. Accessing NT 4.0 Domain account info

7. How to copy accounts from NT server to a Domain

8. API calls for retrieving all the Workgroup/Domain/Computer names on the network

9. changing computer name and domain

10. Accessing computer name and domain

11. Getting all Computer Names from Domain

12. changing computer name and domain

 

 
Powered by phpBB® Forum Software