Bulk-Remove Protection for Accidental Deletion in AD

by Jul 8, 2015

By default, AD objects are protected from accidental deletion. To remove this protection for all objects in a given scope (i.e. all objects in an organizational unit and below), try this code:

#requires -Version 1 -Modules ActiveDirectory

Get-ADObject -Filter * -SearchBase 'OU=TestOU,DC=Vision,DC=local"' |
ForEach-Object -Process {
    Set-ADObject -ProtectedFromAccidentalDeletion $false -Identity $_

Note: This code requires the ActiveDirectory module which ships with the free RSAT tools.

Twitter This Tip! ReTweet this Tip!