Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove machine from Domain to workgroup

Status
Not open for further replies.

NJDEV1K

Programmer
Jan 10, 2004
19
US
I am trying to figure out the best way to script removing a computer from a Domain and adding it to a workgroup. I also then have to add a local user and move the domain profile that was there to the workgroup user's profile. Any suggestions or help would be appreciated.

 
Here is a script I wrote to move PCs from one domain to another. Just leave off the join command if you don't want to add back toa domain.

This script uses a text file to get the workstation names, so you can do a batch of computers easily. You will need to edit with your domain admin ID & password info.

'==========================================================================
'
' NAME: NetDomJoinWorkstations
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: ' DATE : 6/24/2003
'
' COMMENT: Joins computers to a new domain. Edit domain name,
' user ID and passwords below. Uses a workstation list wslist.txt.
' Modification 7/28/2003 to include Remove command. Suggest synchronizing old and new server passwords
'
'==========================================================================

On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("wslist.txt")
'make an array from the data file
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close

For Each strWorkstation In RemotePC
'Do something useful with strWorkstation
Call WSHShell.Run(&quot;cmd.exe /c NETDOM REMOVE &quot; & strWorkstation &&quot;/Domain:<domain> /UserD:<user> /PasswordD:<password> UserO:<user> /PasswordO:<password> /REBoot:30000&quot;)
Wscript.sleep 15000
Call WSHShell.Run(&quot;cmd.exe /c NETDOM JOIN &quot; & strWorkstation &&quot;/Domain:<domain> /UserD:<user> /PasswordD:<password> UserO:<user> /PasswordO:<password> /REBoot:0&quot;)

Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top