Remotely deleting computers from Active Directory

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
adam
Posts: 2
Last visit: Mon Mar 04, 2013 7:49 am

Remotely deleting computers from Active Directory

Post by adam »

I've been banging my head against a wall and need some help here.I need a batch that can run on a client to remotely remove computer names from Active Directory on the server, it also needs to prompt to ask which computer you want to delete.I can achieve this with a vbs that has to be run locally on the server, but I really need to be able to do this on client machines.Any help is much appreciated :)
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

Remotely deleting computers from Active Directory

Post by jhicks »

Sorry nobody got back to you sooner. You could use the DS* commands from a prompt. DSQUERY computer will return all computer accounts. You can also specify an OU to search in. Normally you can pipe output from one DS command into another, but I couldn't get that to work for the DSRM command which will remove AD Objects. But you can do something like this:C:>for /f %c in ('dsquery computer "ou=demo,ou=servers,dc=jdhitsolutions,dc=local"') do @dsrm %cYou will be prompted for each deletion:Are you sure you wish to delete CN=DemoServer01,OU=Demo,OU=Servers,DC=jdhitsolutions,DC=local (Y/N)? Does this help?
User avatar
woowil
Posts: 17
Last visit: Tue Aug 27, 2013 4:15 pm

Remotely deleting computers from Active Directory

Post by woowil »

Hello!

The DS* suite are pretty powerful commands indeed. But in this case I'll use netdom remove /? from Support tools / Reskit for removal om computer acounts.
This topic is 15 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked