# Import the Active Directory module if it's not already loaded
Import-Module ActiveDirectory
# Generate 10 random Organizational Units (OUs)
$ouNames = @('Finance', 'HR', 'IT', 'Sales', 'Marketing', 'Operations', 'Admin', 'Support', 'R&D', 'Logistics')
$ouList = @()
# Root DN (Distinguished Name) to create OUs under
$rootDN = "DC=rajeshalda,DC=local"
# Create the OUs
foreach ($ouName in $ouNames) {
$ouPath = "OU=$ouName,$rootDN"
$ouList += $ouPath
# Check if the OU already exists, if not create it
if (-not (Get-ADOrganizationalUnit -Filter "DistinguishedName -eq '$ouPath'")) {
New-ADOrganizationalUnit -Name $ouName -Path $rootDN
Write-Output "Created Organizational Unit: $ouPath"
} else {
Write-Output "OU already exists: $ouPath"
}
}
# Total number of users to create
$totalUsers = 5000000
# Users per OU (since 10 OUs)
$usersPerOU = 500000
# Loop through OUs and add users
for ($i = 0; $i -lt 10; $i++) {
$ou =...