AD Protected from Accidental Deletion

I ran into something today so I thought I'd post my solution to speed things up for people...

I had to remove a load of sub OUs from our AD.  This seemed  relatively straight forward until I the deletion failed due to all the OUs being protected from accidental deletion.

This is a good thing.

Here's the powershell to disable this: you will need to have the AD powershell add-in...

Import-Module ActiveDirectory

To turn off protection...

Get-ADObject -LDAPFilter "objectclass=organizationalUnit" -SearchBase "OU=UserObjects,OU=USA,DC=CONTOSO,DC=COM" | Set-ADObject -ProtectedFromAccidentalDeletion $false

I then ran the same thing again but set it to true to re-enable the protection

Get-ADObject -LDAPFilter "objectclass=organizationalUnit" -SearchBase "OU=UserObjects,OU=USA,DC=CONTOSO,DC=COM" | Set-ADObject -ProtectedFromAccidentalDeletion $true

Comments

Popular posts from this blog

PXE booting, MDT and 802.1x

Intune installation requires a wire...or does it?

Powershell VPN connections - PEAP with MSCHAPv2