PowerShell New-ADOrganizationalUnit: Create Active Directory OUs
• 3 min read
powershell active-directory new-adorganizationalunit ou-management tutorial
PowerShell New-ADOrganizationalUnit: Complete Guide to Creating OUs
Overview
The New-ADOrganizationalUnit cmdlet creates new organizational units in Active Directory. Used for establishing OU structure, supporting Group Policy scope, and enabling administrative delegation.
Common Tasks:
- Create department OUs
- Create nested organizational structure
- Create location-based OUs
- Create OUs for different security policies
- Build OU hierarchy for delegation
Prerequisites:
- PowerShell 5.1 or later
- Active Directory PowerShell module
- Domain Administrator permissions
- Target parent OU must exist
Syntax
New-ADOrganizationalUnit [-Name] <string> [-Path <string>] [-Description <string>]
[-ProtectedFromAccidentalDeletion <bool>] [-Server <string>]
```powershell
### Key Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| `-Name` | String | OU name (required) |
| `-Path` | String | Parent container distinguished name |
| `-Description` | String | OU description/documentation |
| `-ProtectedFromAccidentalDeletion` | Bool | Prevent accidental deletion |
| `-Server` | String | Domain controller to contact |
---
## Examples
### Example 1: Create Simple OU
```powershell
New-ADOrganizationalUnit -Name "Finance" `
-Path "DC=contoso,DC=com" `
-Description "Finance department users and computers"
```powershell
**Output:** OU created successfully
### Example 2: Create OU with Deletion Protection
```powershell
New-ADOrganizationalUnit -Name "Finance" `
-Path "DC=contoso,DC=com" `
-Description "Finance department" `
-ProtectedFromAccidentalDeletion $true
```powershell
**Benefits:**
- Prevents accidental deletion
- Must explicitly disable protection to delete
- Recommended for all permanent OUs
### Example 3: Create Nested OUs
```powershell
# Create parent OU
New-ADOrganizationalUnit -Name "Users" `
-Path "DC=contoso,DC=com" `
-Description "User accounts organization"
# Create department OUs under Users
New-ADOrganizationalUnit -Name "Finance" `
-Path "OU=Users,DC=contoso,DC=com" `
-Description "Finance department users"
New-ADOrganizationalUnit -Name "IT" `
-Path "OU=Users,DC=contoso,DC=com" `
-Description "IT department users"
New-ADOrganizationalUnit -Name "Sales" `
-Path "OU=Users,DC=contoso,DC=com" `
-Description "Sales department users"
```powershell
### Example 4: Create Deep Nesting for Roles
```powershell
# Level 1: Department
New-ADOrganizationalUnit -Name "IT" `
-Path "OU=Users,DC=contoso,DC=com"
# Level 2: Role
New-ADOrganizationalUnit -Name "Administrators" `
-Path "OU=IT,OU=Users,DC=contoso,DC=com"
New-ADOrganizationalUnit -Name "Technicians" `
-Path "OU=IT,OU=Users,DC=contoso,DC=com"
# Level 3: Location
New-ADOrganizationalUnit -Name "NewYork" `
-Path "OU=Technicians,OU=IT,OU=Users,DC=contoso,DC=com"
```powershell
### Example 5: Create Computer OUs
```powershell
# Create computers root OU
New-ADOrganizationalUnit -Name "Computers" `
-Path "DC=contoso,DC=com" `
-Description "Computer accounts organization" `
-ProtectedFromAccidentalDeletion $true
# Create workstations OU
New-ADOrganizationalUnit -Name "Workstations" `
-Path "OU=Computers,DC=contoso,DC=com" `
-Description "Desktop and laptop computers"
# Create servers OU
New-ADOrganizationalUnit -Name "Servers" `
-Path "OU=Computers,DC=contoso,DC=com" `
-Description "Server computer accounts"
```powershell
### Example 6: Bulk Create from CSV
```powershell
$csv = Import-Csv "C:\ous-to-create.csv"
foreach ($item in $csv) {
try {
New-ADOrganizationalUnit -Name $item.OUName `
-Path $item.ParentPath `
-Description $item.Description `
-ProtectedFromAccidentalDeletion $true `
-ErrorAction Stop
Write-Host "✓ Created: $($item.OUName)"
}
catch {
Write-Host "✗ Failed: $($item.OUName) - $($_.Exception.Message)"
}
}
```powershell
**CSV Format:**
```csv
OUName,ParentPath,Description
Finance,"OU=Users,DC=contoso,DC=com","Finance department users"
IT,"OU=Users,DC=contoso,DC=com","IT department staff"
Sales,"OU=Users,DC=contoso,DC=com","Sales team users"
Workstations,"OU=Computers,DC=contoso,DC=com","Desktop/laptop computers"
Servers,"OU=Computers,DC=contoso,DC=com","Server computer accounts"
```powershell
### Example 7: Create with Error Handling
```powershell
try {
$ou = New-ADOrganizationalUnit -Name "Finance" `
-Path "DC=contoso,DC=com" `
-Description "Finance department" `
-ProtectedFromAccidentalDeletion $true `
-ErrorAction Stop
Write-Host "✓ OU created: $($ou.DistinguishedName)"
}
catch {
if ($_.Exception.Message -like "*already exists*") {
Write-Host "✗ OU already exists"
}
else {
Write-Host "✗ Error: $($_.Exception.Message)"
}
}
```powershell
### Example 8: Create Standard Structure
```powershell
# Function to create standard OU structure
function New-StandardOUStructure {
param(
[string]$DomainDN = (Get-ADDomain).DistinguishedName
)
# Top-level OUs
$ouList = @(
@{Name="Users"; Path=$DomainDN; Desc="User accounts"},
@{Name="Computers"; Path=$DomainDN; Desc="Computer accounts"},
@{Name="Groups"; Path=$DomainDN; Desc="Security and distribution groups"},
@{Name="Servers"; Path=$DomainDN; Desc="Server accounts"}
)
foreach ($ou in $ouList) {
try {
New-ADOrganizationalUnit -Name $ou.Name -Path $ou.Path `
-Description $ou.Desc `
-ProtectedFromAccidentalDeletion $true -ErrorAction Stop
Write-Host "✓ Created: $($ou.Name)"
}
catch {
Write-Host "⚠ $($ou.Name): $($_.Exception.Message)"
}
}
}
New-StandardOUStructure
```powershell
### Example 9: Create Location-Based Structure
```powershell
$locations = @("NewYork", "Boston", "Chicago", "LosAngeles")
foreach ($location in $locations) {
# Create location OU
$locOU = New-ADOrganizationalUnit -Name $location `
-Path "DC=contoso,DC=com" `
-Description "$location office location" `
-ProtectedFromAccidentalDeletion $true
# Create sub-OUs
New-ADOrganizationalUnit -Name "Users" `
-Path $locOU.DistinguishedName `
-Description "Users in $location"
New-ADOrganizationalUnit -Name "Computers" `
-Path $locOU.DistinguishedName `
-Description "Computers in $location"
Write-Host "✓ Created location structure: $location"
}
```powershell
### Example 10: Create with Policies OU
```powershell
# Create structure for policy organization
New-ADOrganizationalUnit -Name "Policies" `
-Path "DC=contoso,DC=com" `
-Description "Organizational units for Group Policy organization" `
-ProtectedFromAccidentalDeletion $true
# Create policy-specific OUs
$policies = @(
"HighSecurity",
"StandardSecurity",
"LowSecurity",
"TestEnvironment"
)
foreach ($policy in $policies) {
New-ADOrganizationalUnit -Name $policy `
-Path "OU=Policies,DC=contoso,DC=com" `
-Description "$policy computers and users"
}
```powershell
---
## Best Practices
✅ **Always Enable Deletion Protection**
- Prevents accidental OU deletion
- Especially important for permanent OUs
- Must explicitly disable to delete
✅ **Use Meaningful Names**
- Department names (Finance, IT, Sales)
- Location names (Boston, NewYork)
- Descriptive, not generic (avoid "OU1", "OU2")
✅ **Include Descriptions**
- Document OU purpose
- Include contact person
- Note any special configurations
✅ **Plan Structure Before Creating**
- Document hierarchy
- Consider GPO requirements
- Design for scalability
✅ **Keep Nesting Reasonable**
- Limit to 3-5 levels
- Avoid excessive nesting
- Balance organization with management complexity
✅ **Test Before Bulk Creation**
- Create sample OUs first
- Verify structure works
- Then bulk import from CSV
---
## Common Mistakes
❌ **Creating OUs at Same Level as Users**
- Mixes departments with users
- Makes delegation difficult
✅ **Better:** Create top-level "Users" OU, then nested departments
❌ **No Deletion Protection**
- Accidental deletion causes data loss
✅ **Better:** Always use `-ProtectedFromAccidentalDeletion $true`
❌ **Inconsistent Naming**
- Finance, finance, FINANCE, Fin
- Confusing and unprofessional
✅ **Better:** Consistent naming: Finance, IT, Sales, HR
❌ **Over-Nesting**
- 6+ levels deep
- Complex management
✅ **Better:** 3-4 levels maximum
---
## Troubleshooting
### Problem: Parent OU Doesn't Exist
```powershell
# Check if parent OU exists
Get-ADOrganizationalUnit -Filter "DistinguishedName -eq 'OU=Users,DC=contoso,DC=com'"
# Create parent first
New-ADOrganizationalUnit -Name "Users" -Path "DC=contoso,DC=com"
```powershell
### Problem: Permission Denied
```powershell
# Verify you're Domain Admin
Get-ADUser $env:USERNAME | Get-ADPrincipalGroupMembership | Select-Object Name
# May need to run as different user
# Run PowerShell as Domain Admin
```powershell
### Problem: OU Name Already Exists
```powershell
# Check for existing OU
Get-ADOrganizationalUnit -Filter "Name -eq 'Finance'" `
-SearchBase "DC=contoso,DC=com"
# Use different name or different path
```powershell
---
## FAQs
### Q: Can I create OUs with special characters?
A: Avoid special characters. Use alphanumeric and hyphens. Example: "Finance-2024", not "Finance@2024"
### Q: What's the maximum OU nesting depth?
A: Technically unlimited, but keep it under 5 levels for management.
### Q: Can I rename an OU after creation?
A: Yes, use `Rename-ADObject`. Example:
```powershell
$ou = Get-ADOrganizationalUnit -Filter "Name -eq 'OldName'"
Rename-ADObject -Identity $ou -NewName "NewName"
```powershell
### Q: How do I move an OU to different parent?
A: Use `Move-ADObject`. Example:
```powershell
$ou = Get-ADOrganizationalUnit -Filter "Name -eq 'Finance'"
Move-ADObject -Identity $ou -TargetPath "OU=Users,DC=contoso,DC=com"
```powershell
### Q: Can I undo OU creation?
A: Yes, delete with `-ProtectedFromAccidentalDeletion $false` first, then remove.
---
## Related Commands
- **[Get-ADOrganizationalUnit](/powershell-get-adorganizationalunit)** - Query OUs
- **[Set-ADOrganizationalUnit](/powershell-set-adorganizationalunit)** - Modify OUs
- **[Remove-ADOrganizationalUnit](/powershell-remove-adorganizationalunit)** - Delete OUs
- **[Move-ADObject](/powershell-move-objects-ou)** - Move OUs/objects
---
## See Also
- **[Active Directory OU Overview](/active-directory-ou)** - OU concepts
- **[Active Directory OU Structure](/active-directory-ou-structure)** - Design patterns
- **[PowerShell Get-ADOrganizationalUnit](/powershell-get-adorganizationalunit)** - Query OUs
---
**Last Updated:** February 6, 2026
**Difficulty Level:** Intermediate
**Reading Time:** 8 minutes