Bulk-Remove Protection for Accidental Deletion in AD

by | July 8,2015

Table of Contents

Removing Accidental Deletion Protection

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 $_
}

Requirement: ActiveDirectory Module

Note: This code requires the ActiveDirectory module which ships with the free RSAT tools.
ReTweet this Tip!