Hi, I am trying to delete a computer object from AD OU but everytime the computer has a subtree object (when AD says the object contain other objects) it cannot be deleted via PYAD. Is there any way to force the deletion of this kind of object.
My code:
pyad.adcomputer.ADComputer.from_dn("CN=MYSERVER,OU=Servers AZ,OU=Servers,DC=mydomain,DC=local").delete()
Outcome
Traceback (most recent call last):
File "", line 1, in
File "C:\Python37-32\lib\site-packages\pyad\adobject.py", line 540, in delete
parent.remove_child(self)
File "C:\Python37-32\lib\site-packages\pyad\adcontainer.py", line 96, in remove_child
self._ldap_adsi_obj.Delete(child.type, child.prefixed_cn)
File "<COMObject >", line 2, in Delete
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Active Directory', 'The directory service can perform the requested operation only on a leaf object.\r\n', None, 0, -2147016683), None)
I have also tried this command, but got the same outcome:
pyad.adcomputer.ADComputer.from_cn("MYSERVER").delete()
I need something that performs the same as this in Powershell:
xample 4: Remove a computer and all leaf objects that are located under a specified directory
PowerShell
Hi, I am trying to delete a computer object from AD OU but everytime the computer has a subtree object (when AD says the object contain other objects) it cannot be deleted via PYAD. Is there any way to force the deletion of this kind of object.
My code: pyad.adcomputer.ADComputer.from_dn("CN=MYSERVER,OU=Servers AZ,OU=Servers,DC=mydomain,DC=local").delete()
Outcome Traceback (most recent call last): File "", line 1, in
File "C:\Python37-32\lib\site-packages\pyad\adobject.py", line 540, in delete
parent.remove_child(self)
File "C:\Python37-32\lib\site-packages\pyad\adcontainer.py", line 96, in remove_child
self._ldap_adsi_obj.Delete(child.type, child.prefixed_cn)
File "<COMObject >", line 2, in Delete
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Active Directory', 'The directory service can perform the requested operation only on a leaf object.\r\n', None, 0, -2147016683), None)
I have also tried this command, but got the same outcome: pyad.adcomputer.ADComputer.from_cn("MYSERVER").delete()
I need something that performs the same as this in Powershell: xample 4: Remove a computer and all leaf objects that are located under a specified directory PowerShell
PS C:> Get-ADComputer -Identity "USER01-SRV4" | Remove-ADObject -Recursive Source: https://docs.microsoft.com/en-us/powershell/module/dnsserver/remove-dnsserverresourcerecord?view=win10-ps