Active Directory Administration

Published by harrisonjonesit.co.uk on

Active Directory Administration

I use On-Premise and Azure Active Directory on a daily basis in my job. However when I started the environment was already set up with plenty of users, groups, OU’s ETC so I decided to create my own virtual environment and fill it with users and groups from PowerShell.

Firstly, I created a Virtual Server in Virtual box. this acts as my domain controller. I then created a virtual windows 10 client that will act as the regular using when connecting to the DC and later the internet. please see the network diagram below for a visual demonstration.

I used a PowerShell Script created by ChatGPT to create 1,000 users in AD to replicate a large business. overall this was a great introduction to windows networking and has allowed me to own my own business style AD Domain for any future projects or testing. If interested see PowerShell script below which worked from ChatGPT first try.

$PASSWORD_FOR_USERS = "Password1"
$USER_FIRST_LAST_LIST = Get-Content .\names.txt

------------------------------------------------------

$password = ConvertTo-SecureString $PASSWORD_FOR_USERS -AsPlainText -Force
New-ADOrganizationalUnit -Name _USERS -ProtectedFromAccidentalDeletion $false

foreach ($n in $USER_FIRST_LAST_LIST) {
$first = $n.Split(" ")[0].ToLower()
$last = $n.Split(" ")[1].ToLower()
$username = "$($first.Substring(0,1))$($last)".ToLower()
Write-Host "Creating user: $($username)" -BackgroundColor Black -ForegroundColor Cyan
New-AdUser -AccountPassword $password `
           -GivenName $first `
           -Surname $last `
           -DisplayName $username `
           -Name $username `
           -EmployeeID $username `
           -PasswordNeverExpires $true `
           -Path "ou=_USERS,$(([ADSI]`"").distinguishedName)" `
           -Enabled $true

Categories: Blog