Remove old Active Directory computer accounts from SCCM

A common issue in IT organizations is that the removal of computer objects is not done regularly. While I’ve presented scripts for removing old computer accounts from Active Directory, I’ve recently had to extend the removal of legacy computers into other systems such as SCCM.

Because SCCM dynamically discovers computers, but does not remove them I’ve created this short script which scans the Active Directory for computer accounts which have been off the network for more than a certain number of days (45 is my preferred number).

The next thing that you will need to do is to make sure that you move those computer accounts to an OU which is not discoverable by SCCM, or delete them from Active Directory altogether so that they are not re-discovered. This script simply removes them from SCCM.

The code at the end of the article is also stored at my TechNet Gallery page here or you can go directly to the article from this link: