The Best Practice Analyzer issues a warning if not all organizational units (OUs) of the organization are protected against accidental deletion. If you don't want to go to the trouble of clicking on all OUs individually and activating the protection, you can let Powershell do the work for you.
On the Powershell, we first import the Active Directory module:
Import-module activedirectory
We then set the "ProtectedFromAccidentalDeletion" parameter for all OUs:
Get-ADOrganizationalUnit -Filter {Name -like "*"} | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true
Depending on how many OUs there are in the organization, it may take some time to execute the command.
Syntax Error:
Get-ADOrganizationalUnit : Fehler beim Analysieren der Abfrage: „Name -like „*““ Fehlermeldung: „syntax error“ an folge
nder Position: „12“.
Bei Zeile:1 Zeichen:25
+ Get-ADOrganizationalUnit <<<< -Filter {Name -like "*"} | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $
true
+ CategoryInfo : ParserError: (:) [Get-ADOrganizationalUnit], ADFilterParsingException
+ FullyQualifiedErrorId : Fehler beim Analysieren der Abfrage: "Name -like "*"" Fehlermeldung: "syntax error" an f
olgender Position: "12".,Microsoft.ActiveDirectory.Management.Commands.GetADOrganizationalUnit