I was trying to delete user object from active directory, which had mailbox, skype for business user, etc..etc.
But was getting the error "Remove-ADUser : The directory service can perform the requested operation only on a leaf object"
After search on internet i found the i should use the Remove-Adobject command, also need to use the user distinguish name
and then with -recursive attribute.
Remove-ADobject (Get-ADUser sAMAccountName).DistinguishedName -Recursive
I you want to avoid any confirmation for deletion of the user object then can use -confirm attribute
as below.
Remove-ADobject (Get-ADUser sAMAccountName).DistinguishedName -Recursive -Confirm:$false
No comments:
Post a Comment