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 computer from domain without domain present

Status
Not open for further replies.

slint

Technical User
Jul 2, 2006
48
SE
Hi U all..

Is there a way to do as follow by script.

I'm about to change domain on our network (1000 clients) The former admin dident set things upp right and it's time for a littel cleaning. The old domain is location.mydomain.com and the new domain is mydomain.com, bacause the two domains overlap i cant have them on the same network. So i have to change to the new domain without having the old domain present. And as i have tested i have discovered that i cant use netdom without having both domains present. My task is to move the computers to a workgroup then change computername and finaly add it to the new domain. I'm not going to do this by logonscript, i am going to go to every computer and make the proper changes (me and 5 other people that dont have computer experiens, so i have to have it flawless). I have looked a littel on the microsoft example and i cant get the hang of it. The microsoft example is this. All the computers in the network is Windows XP.

Can someone explain the script for me and try to explain how i should crack this beast...

Thanks for all help i could get..

UnJoin script..
Code:
Const NETSETUP_ACCT_DELETE = 2 'Disables computer account in domain.
strPassword = "password"
strUser = "kenmyer"

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
 strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
strDomain = objComputer.Domain
intReturn = objComputer.UnjoinDomainOrWorkgroup _
 (strPassword, strDomain & "\" & strUser, NETSETUP_ACCT_DELETE)

Join script
Code:
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
 
strDomain = "FABRIKAM"
strPassword = "ls4k5ywA"
strUser = "shenalan"
 
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
 
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
        strComputer & "'")
 
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, strDomain & "\" & strUser, NULL, _
        JOIN_DOMAIN + ACCT_CREATE)
 
Before delving into the scripts you are proposing, let's talk about just doing a migration since the old domian (location.mydomain.com) is going away. I'm not clear on the overlap issue. Can you explain the issue you are having? I am assuming the domains are in independent forests. If so, you should be able to build a forest trust and migrate all you user, group, and computer objects using AD Migration Utility.


If the above isn't an option and you have to script this, here is the link to the Microsoft Scripting Guide:
 
Thats the prob.. the ad is so filty so a migration is not a question. We have created all the objekts in the new ad after a new standard so it's only the computers left. But i understand your point. A migration had been a good way if the ad was in good shape, but it isnt. And this is also a reason way we not want to bild trusts between the domians.
 
OK...
Take the time this weekend and go over the Scripting Guide. You wont become an expert over night but I think it will help you decide on the best option when creating the script. You have over a 1,000 workstations to move into your new domain and your requirement is to do is quickly without user impact.
Figure out how you want to do this, not in code, but just simple terms. There are a lot of people here who can steer you in the proper direction. Continue to post in this thread...
 
I'l be back...

I will come up with an actionplan and post it here as soon as it's finished. And i will try to compile a script but i'm going to need help.

Thanks for now, WhoKilledKenny
 
I don't understand why you think you can't remove a computer from the existing domain. All that is required is to first move to a workgroup and then move to the new domain. This must be done with local admin rights.

The way I would do this is I would use ADMT to migrate the workstations.



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top