Protecting all Organizational Units (OUs) from accidental deletion

You can protect your organizational Units from accidental deletion by using Power Shell scripts to apply the protection to many organizational units at once. You can run these Power shell commands by running the Active Directory Module for Windows PowerShell as Administrator and making sure that you have Domain Admins or Enterprise Admins rights.

First type the following command to check which OUs are not protected:

Get-ADOrganizationalUnit -filter * -Properties ProtectedFromAccidentalDeletion | where {$_.ProtectedFromAccidentalDeletion -eq $false} | ft

Type the following command to protect the OUs that you have identified in the above command:

Get-ADOrganizationalUnit -filter * -Properties ProtectedFromAccidentalDeletion | where {$_.ProtectedFromAccidentalDeletion -eq $false} | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true

After this command is successfully completed, you can re-run the first command to make sure that all Organizational Units (OUs) have been protected.

Read my favorites blogs:

Assigning File Share permissions using Power Shell

Disk Read Error when migrating virtual machine from one cluster to another

Designing a backup less Exchange 2010 Architecture

Step by step guide for upgrading Active Directory from Microsoft Windows 2008 R2 to Microsoft Windows Server 2012 R2

Microsoft Exchange 2010 Test cases

Microsoft Exchange 2013 and ADRMS Integration