"Remove-Computer" or "Remove-ADComputer" - which is best?

Dwight Baer
Dwight Baer used Ask the Experts™
on
I'm using Windows Server 2012 R2 - trying to remove a computer from a domain using PowerShell.

Which command is best, and how are the results different?
1.  Remove-ADComputer -Identity "Server01"
(See https://technet.microsoft.com/en-us/library/ee617250.aspx )

OR

2.  Remove-Computer -Computername Server01 -UnjoinCredential domainname\administrator -Passthru -Verbose -Force -Restart
(See https://technet.microsoft.com/en-us/library/hh849816(v=wps.620).aspx  )

Thanks a lot.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Remove-ADComputer is usually the preferred method.
Remove-ADComputer -Identity "Server01" is a preferred methid
Dwight BaerStudent
Commented:
Great, thanks.

But why are there two commands and why is remove-ADComputer better?  Just curious.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Remove-Computer removes the local computer from their current domains.
Remove-ADComputer removes an Active Directory computer.
Dwight BaerStudent

Author

Commented:
Ah ... Remove-ADComputer is more mulit-purpose.  OK.
Dwight BaerStudent

Author

Commented:
Thanks, both.
Top Expert 2014
Commented:
Remove-ADComputer operates just on AD and deletes the computer account from AD.

Remove-Computer operates on a local or remote machine and unjoins a computer from a domain, making it a member of a workgroup, and the AD account gets disabled.

So what you use depends on your intentions.  If you wanted to use the workstation as part of a workgroup or later rejoin it to the domain you'd probably use Remove-Computer.  If you just use Remove-ADComputer the workstation won't have any idea, it's corresponding info in AD would be removed right out from under it so it wouldn't be able to authenticate to the domain, etc.  That'd be fine if you're just going to wipe the machine.

Edit:  looks like you closed the question while I was typing this up.  Oh, well.
Dwight BaerStudent

Author

Commented:
Sorry, the "supplementary question" was a bit of an afterthought, I didn't actually mean to close the question!  Thanks very much for your answer, footech.  Sorry about the points.
Dwight BaerStudent
Commented:
Update:  Now that I've researched this further, I think the first two answers are wrong, and footech's answer is the one I should have accepted as correct.  Remove-ADComputer should ONLY be used when you plan to wipe your computer and you don't care what's on it.

Although it's a bit more complex to use, remove-computer is the tool that should usually be used.

Is there any  way that I can re-open this question and close it again as per the above?
The "Request attention" button found at the bottom of the question block will notify an admin. Just explain in the box what you would like done. In a case like this, the question can be reopened.
Dwight BaerStudent

Author

Commented:
Thanks again.  I thought I had closed this.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial