20

I lost my domain controller machine, and then add new domain controller but with a new domain. How do I remove network machines from old domain using command line and add to new domain? Machines using Windows Server 2008 Core (command line only)

net computer \\name del

works only on domain controller.

sconfig

When I try to exit from old domain, console requests username and password for exit. I type it, and then get error "Could not connect to domain" (old domain controller not exists)

What to do?

abatishchev
  • 541
  • 1
  • 9
  • 31
Dmitriy Kudinov
  • 303
  • 1
  • 2
  • 6

2 Answers2

24

Try netdom remove computername /Domain:domain /UserD:user /PasswordD:* /Force

Type netdom remove /? for the full command usage. The /Force option is what you're looking for. Per the help:

Forces the unjoin of the machine from the domain even if the domain is not found or does not contain the matching computer object.

To join the members to the new domain: netdom join computername /Domain:domain /UserD:user /PasswordD:*

Again type netdom join /? for help with the command usage.

mweisel
  • 556
  • 3
  • 4
  • 4
    For those of you lacking the netdom executable, this can be installed as part of the [RSAT (W8.1)](http://www.microsoft.com/en-gb/download/details.aspx?id=39296) / [RSAT (W7)](http://www.microsoft.com/en-gb/download/details.aspx?id=7887) package. Download, install, then go to _Control Panel_ > _Turn Windows features on or off_. Under RSAT select _AD DS Snap-ins and Command-line Tools_ as per [screenshot](https://i.imgur.com/ZMfGPqU.png). – Chris Pickford Feb 09 '15 at 18:33
  • 5
    What's the point of the `/domain` etc? `netdom remove computername /force` worked perfectly for me. – Pieter van Ginkel May 18 '16 at 18:39
  • `netdom remove computername /force` is sufficient! – Riley Feb 06 '18 at 11:15
  • this was the only way i was able to get ansible to unjoin a pc from domain after it lost its security ids for the name, somehow it wasnt fully joined. awesome thanks! – Brian Thomas Jul 15 '23 at 00:22