Powershell – Delete Computer Object in AD with Powershell

active-directorydeploymentpowershellscriptingwindows 7

I am able to use the native add-computer cmdlet to join a computer to a domain, but it seems that this cmdlet fails if the systems already exists in AD, and you are trying to add it to a different domain.

I would like to delete the existing object with powershell. Is this possible without loading the Active Directory Module? I am doing all this as part of system deployment, and don't want to have to load any additional windows features.

EDIT:
This will need run in a way where I can pass credentials to the command. It will be run in the context of a local user.

Best Answer

I would suggest using DSRM CLI-tool, which is awesome.

DSRM description and usage examples - Technet

NOTE: it's not available on W7, but *.exe files can be extracted from Windows Server 2008 machine.

How can i get DSRM.exe to work without installing RSAT