If you come across this error when using Powershell to delete an object, it is most likely because the object has child objects associated with it. The most obvious example is computer objects that have print queue, service connection point, RRAS or various other types of child objects. The workaround is to determine the child object (to see if it might be required) and then to delete the objects recursively as shown below.
In this example we have a computer object named “Foo”. If we try and delete it using the Powershell AD cmdlet Remove-ADComputer we see the “leaf object: error.
We can then use some other Powershell goodness to determine the type of child object that we have. In this case a service connection point object.
Once we’re happy that deleting the child object won’t cause any other issues, we can use the Remove-ADObject cmdlet together with the –Recursive switch to delete both the computer and the service connection point objects.
Very Great Trik…
Great this has helped me out of a hole. 🙂
Thank you very much! It helped!