# How to Remove the computer from the AD domain using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

#### Powershell for beginners

15 Lectures 3.5 hours

#### Learning Task Automation using Windows PowerShell

35 Lectures 2.5 hours

#### The Complete PowerShell 7 course: Beginner To Advanced

Most Popular

145 Lectures 12.5 hours

To remove the computer from the domain we need to use the Remove-Computer command.

Remove-Computer -ComputerName Test1-win2k16
-UnjoinDomainCredential Labdomain\Administrator 
-WorkgroupName WG -Restart -Force -PassThru

In the above example, the Computer name Test1-Win2k16 is going to remove from the domain with the domain credentials and it will be joined to WorkGroup named WG. If the system doesn’t restart due to any reason, you need to reboot the system manually.

Here the computer name is the String[]. So you can provide multiple computers to remove from the domain. For example,

Remove-Computer -ComputerName Test1-win2k16, Test1-Win2k12
-UnjoinDomainCredential Labdomain\Administrator 
-WorkgroupName WG -Restart -Force -PassThru
Updated on 28-Dec-2020 07:01:58