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

PowerShellMicrosoft TechnologiesSoftware & Coding

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
raja
Published on 28-Dec-2020 07:01:58
Advertisements