Public/Unprotect-AllOUs.ps1
function Unprotect-AllOUs { <# .SYNOPSIS Remove the "Protected from accidental deletion" flag from all OUs .DESCRIPTION Remove the "Protected from accidental deletion" flag from all OUs .NOTES Author : Marc Bouchard - @subnet192 .DEPENDENCIES ActiveDirectory module required .INPUTS No inputs required .OUTPUTS None .EXAMPLE Unprotect-AllOUs #> <# ----------------------------------------------------------[Declarations]---------------------------------------------------------- #> $ADDomain = Get-ADDomain $searchbase = $ADDomain.DistinguishedName <# -----------------------------------------------------------[Execution]------------------------------------------------------------ #> Get-ADOrganizationalUnit -searchbase $searchbase -filter * -Properties ProtectedFromAccidentalDeletion | where { $_.ProtectedFromAccidentalDeletion -eq $true } | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $false } #END function |