Protect Multiple objects from accidental deletion via AD PowerShell

By |2017-12-08T14:34:45+00:00August 15th, 2011|PowerShell|0 Comments

Recently we got tasked with protecting all objects in a specific  OU from accidental deletion. There were about 60 users in this OU so we wanted to script this and by scripting this we would also be able to set up a scheduled task so that the change got applied to new users who got added to the OU also.

First of all open PowerShell and run “Import-Module activedirectory”

Now run the following but obviously change the DN name so that it points at the OU relevant for your domain.

Get-ADobject -Filter * -SearchBase “OU=Users,DC=Domain,DC=com” | Set-adobject -ProtectedFromAccidentalDeletion $true

All users in the OU should now be protected from accidental deletion Smile

Leave A Comment

like what you see? 

Sign-up to our newsletter and never miss out on the latest blogs, events and tech news from the world of risual
SUBSCRIBE!
Give it a try, you can unsubscribe anytime.