Organizational Units (OUs) in Active Directory are used to categorize and manage objects, such as user accounts, computer accounts, and groups. OUs allow administrators to delegate control, apply group policies, and enforce security policies. In some cases, it may be necessary to redirect the default container for user and computer accounts to a different OU. Redirecting the default container for user and computer accounts in Active Directory is a powerful way to manage and secure objects in the directory. By using PowerShell scripts, administrators can automate and streamline the process, improving efficiency and reducing the risk of errors.
Redirection of the default container in Active Directory can be done using the following steps:
- Create a new organizational unit (OU) where the user and computer accounts will be redirected.
- Determine the current default container for user and computer accounts.
- Modify the default container for user and computer accounts to the new OU.
The following PowerShell script can be used to redirect the default container for user accounts to a new OU:
Import-Module ActiveDirectory
$OU = "OU=Users,DC=domain,DC=local"
$DefaultContainer = (Get-ADDefaultDomainPasswordPolicy).UserContainer
Set-ADDefaultDomainPasswordPolicy -Identity $DefaultContainer -UserContainer $OU
The following PowerShell script can be used to redirect the default container for computer accounts to a new OU:
Import-Module ActiveDirectory
$OU = "OU=Computers,DC=domain,DC=local"
$DefaultContainer = (Get-ADDefaultDomainPasswordPolicy).ComputerContainer
Set-ADDefaultDomainPasswordPolicy -Identity $DefaultContainer -ComputerContainer $OU
It is important to note that redirecting the default container for user and computer accounts can have significant impact on the Active Directory structure and security. Before making any changes, it is recommended to carefully consider the impact and to test the changes in a lab environment.
You can also use the following command to redirect Users and Computers OU.
For Computers:
redircmp "OU=computers,DC=domainName,DC=local"
For Users:
redirusr “OU=users,DC=DomainName,DC=com”