AD – Removing computers that are inactive (Powershell)

We recently needed to remove computers in our Active Directory environment that have not connected in over 180 days. I decided to whip something up in powershell that we could run as an automated task!

Notes:
– Failsafe to make sure you enter a limit greater than 90(don’t want to delete everything by accident right?)
– Credentials are stored clear text
– Logs output to file and purges old logs based on specified time
– I have to try/catch twice nested to solve the issue of objects that are not leafs

0 comments… add one

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.