PowerShell Command to run on your Windows 2008 R2 DC’s to prevent accidental deletion of objects on a specific OU

2017-12-08T14:24:48+00:00 May 25th, 2012|PowerShell, Windows|

Here is a quick command you can run to protect an OU’s objects.

In this Example the OU we’re protecting is “OU=Users,OU=Test,DC=Test,DC=com”

Get-ADobject -Filter * -SearchBase "OU=Users,OU=Test,DC=Test,DC=com" | Set-adobject -ProtectedFromAccidentalDeletion $true

Now all the objects in the OU will be protected.