Today I got request from our MIS staff to remove about 1000 computer records from AD. Of course some script needed. Here is 5-minutes solution (use with caution!):
- Install PowerShell
- Install ActiveRoles Management Shell for Active Directory
- Put list of all computers to file. For example targets.txt
- Run powershell
- Import ActiveRoles Management Shell:
Add-PSSnapin Quest.ActiveRoles.ADManagement
- Run this:
gc C:\scripts\targets.txt| % { Get-QADComputer -name $_ } | % { Remove-QADObject -force $_.DN }
And one more time – use with extreme caution. Be sure you are removing exactly what you need.