How to remove the several Organization Units that are protected against accidental deletion

Share this:

In some situation an entire structure of Organization Units must be deleted, and by default new OUs are automatic defined to protect them against deletion which requires the administrator to uncheck a property on each OU before deleting the entire structure.

Solution


Let’s use the following scenario, where we are trying to delete the Argentina OU and all its sub-OUs using Active Directory Users and Computers. We need to select the desired parent OU, and then remove it, a new dialog box asking for confirmation will be displayed, click on Yes.

image

The following dialog box will be displayed

Screen Shot 2017-05-05 at 9.43.53 AM

If the Organization Unit is configured against accidental deletion the following error message will be displayed, click on OK.

image

The solution for a single OU is simple, click on Properties, and click on Object tab. Uncheck the Protect object from accidental deletion and then try to delete and it will work.

image

However, if we are trying to delete an entire tree of OUs, then we need to uncheck every single OU from the tree. The best way to do that is using PowerShell, we can use the following cmdlet to retrieve of all Organization Units starting on the Argentina OU.

Get-ADOrganizationalUnit –Filter * –SearchBase “ou=Argentina,dc=domain,dc=local”

image

After confirming that we have all OUs underneath Argentina are being listed, then we need to uncheck that property from each OU and we can do that using the following cmdlet.

Get-ADOrganizationalUnit –Filter * –SearchBase “ou=Argentina,dc=domain,dc=local” | Set-ADObject =ProtectedFromAccidentalDeletion $False

image

After running the cmdlet above, we can try again to delete the entire Organization Unit tree.

Written by Anderson Patricio

Anderson Patricio

Anderson Patricio is a Canadian MVP in Cloud and Datacenter Management, and Office Server and Services, besides the Microsoft Award he also holds a Solutions Master (MCSM) in Exchange and several other certifications. Anderson has been contributing to the Microsoft Community with articles, tutorials, blog posts, twitter, forums and book reviews. He is a regular contributor here at ITPROCentral.com, MSExchange.org, Techgenix.com and Anderson Patricio.org (Portuguese).

Related Post

Exporting PSTs based on Organization Unit In some scenarios the administrator may want to export all mailboxes of a specific OU to PST. Using Exchange Server 2013/2016 this can be accomplished...
Getting the number of mailboxes per database in yo... How to create a single line PowerShell to retrieve the number of mailboxes per mailbox database in your organization. I was asked about that number in...
Running PowerShell on Mac OS PowerShell for everyone! In this Tutorial we are going the installation process on Mac OS.SolutionThe first step is to download the .pkg file which is...
How to configure an OU as default for new objects ... In this Tutorial we will configure an Organization Unit as new default location for new users. By default, all new objects created by Exchange for exa...