How To Create OU's and Nested OU's in Active Directory

Adding Users in ADDS


Adding Organizational Units (OUs) in Active Directory using PowerShell is a streamlined process that can save administrators a lot of time, especially when dealing with large environments. Here’s a step-by-step guide to help you get started:

Prerequisites

Before you begin, ensure you have the Active Directory module for Windows PowerShell installed. You can install it via the Remote Server Administration Tools (RSAT) if it's not already available.

Step-by-Step Guide

  • "Open PowerShell as Administrator":
    • Right-click on the PowerShell icon and select "Run as Administrator".
  • "Import the Active Directory Module":
    • Run the following command to import the Active Directory module:

Import-Module ActiveDirectory

  • "Create a New Organizational Unit":
    • Use the `New-ADOrganizationalUnit` cmdlet to create a new OU. Here’s a basic example:
New-ADOrganizationalUnit -Name "UserAccounts" -Path "DC=YourDomain,DC=com"

    • This command creates an OU named "UserAccounts" in the specified domain path.
  • "Add Additional Attributes":
    • You can add more attributes to the OU, such as description or protection from accidental deletion:
New-ADOrganizationalUnit -Name "UserAccounts" -Path "DC=YourDomain,DC=com" -Description "OU for user accounts" -ProtectedFromAccidentalDeletion $True

  • "Creating Nested OUs":
    • To create nested OUs, specify the path of the parent OU:

New-ADOrganizationalUnit -Name "Admins" -Path "OU=UserAccounts,DC=YourDomain,DC=com"


  • "Using a Script for Bulk Creation":
    • For creating multiple OUs, you can use a PowerShell script. Here’s a simple example:
$OUs = @(
@{Name="HR"; Path="DC=YourDomain,DC=com"},
@{Name="IT"; Path="DC=YourDomain,DC=com"},
@{Name="Finance"; Path="DC=YourDomain,DC=com"}
)
foreach ($OU in $OUs) {
New-ADOrganizationalUnit -Name $OU.Name -Path $OU.Path
}


Using PowerShell to manage Active Directory OUs can significantly enhance efficiency and accuracy. By automating these tasks, administrators can focus on more strategic activities, ensuring a well-organized and secure directory structure.

You can also watch the below YouTube video to learn on Adding Bulk Users in Windows Server 2022




The Excel Sheets and PowerShell scripts discussed on this video can be downloaded from here 

Feel free to ask if you need further assistance or have any questions!
Previous Post Next Post