How to query and delete old Computer Objects from Active Directory

Posted by paris on Jul 12, 2017 in Random |

Query computer objects which have been inactive for 8 weeks in a specific OU

dsquery computer “OU=Computers,OU=OUNAME,DC=domain,DC=local” -inactive 8 

Query computer objects which have been inactive for 8 weeks in a specific OU and name starts with PCNAME

dsquery computer “OU=Computers,OU=OUNAME,DC=domain,DC=local” -inactive 8 -name PCNAME* 

Open the Command Prompt now as Administrator

Query THEN DELETE computer objects which have been inactive for 8 weeks in a specific OU and name starts with PCNAME

dsquery computer “OU=Computers,OU=OUNAME,DC=domain,DC=local” -inactive 8 -name PCNAME* | dsrm -noprompt

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Tags: , , , , ,

Reply

Copyright © 2017 Welcome to Pariswells.com All rights reserved. Theme by Laptop Geek. Privacy Policy