troubleshooting Question

Bulk deletion of computer and user accounts in Active Directory not working

Avatar of Indie101
Indie101 asked on
PowershellActive Directory
12 Comments2 Solutions133 ViewsLast Modified:
Looking to delete computer accounts and user accounts in Active Directory

Got below script for computer accounts previously

Import-Csv -Path C:\Temp\DisableComputer.csv | ForEach-Object {Remove-ADComputer -Identity $_.Name -WhatIf}

It ran fine above then I changed it to below to run it properly

Import-Csv -Path C:\Temp\DisableComputer.csv | ForEach-Object {Remove-ADComputer -Identity $_.Name}

Problem is it doesnt perform deletion of computer accounts in a batch, have to do it one by one and see below error

Remove-ADComputer : The directory service can perform the requested operation only on a leaf object

Looking for a way to bulk delete and also modification required to bulk delete AD user accounts also
Join our community to see this answer!
Unlock 2 Answers and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros