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