One script creates the whole tree. Every OU it makes is protected from accidental deletion.
Create the OUs
Either DC
$root = (Get-ADDomain).DistinguishedName
New-ADOrganizationalUnit -Name "Contoso School" -Path $root -Description "Top OU for Contoso School"
$top = "OU=Contoso School,$root"
$tree = [ordered]@{
"CON-Servers" = "CON-Infrastructure", "CON-Application"
"CON-Workstations" = "CON-Staff-Devices", "CON-Student-Devices"
"CON-Users" = "CON-Staff", "CON-Students"
"CON-Admins" = @()
"CON-Service-Accounts" = @()
"CON-Groups" = @()
}
foreach ($ou in $tree.Keys) {
New-ADOrganizationalUnit -Name $ou -Path $top
foreach ($child in $tree[$ou]) {
New-ADOrganizationalUnit -Name $child -Path "OU=$ou,$top"
}
}Check the result
Either DC
Get-ADOrganizationalUnit -SearchBase $top -Filter * -Properties ProtectedFromAccidentalDeletion | Sort-Object DistinguishedName | Select-Object Name, ProtectedFromAccidentalDeletion, DistinguishedName
You should see 14 OUs, all with ProtectedFromAccidentalDeletion True.
Prefer the graphical tools?
WhereActive Directory Users and Computers›right-click the domain›New›Organizational Unit
Leave Protect container from accidental deletion ticked.
Done when
Check
The tree in Active Directory Users and Computers matches the one on the previous page.


