Learn › Windows Server

Active Directory Basics: Users, Groups and OUs

Active Directory basics: how domains, OUs, users and groups fit together, plus creating users and resetting passwords in the GUI and PowerShell.

Beginner 11 min read
By Gopinath Karthikeyan

Active Directory (AD) is the phone book and the gatekeeper of a Windows network. It stores who the users and computers are, which groups they belong to, and – through those groups – what they’re allowed to do.

Lab: promote a test VM to a domain controller for a new forest such as contoso.local, or use your company’s test domain if you have rights there. Never practise on production AD.

The building blocks

Term What it is
Domain A boundary of users, computers and policies, e.g. contoso.local
Domain controller (DC) A server that runs AD and answers logon requests. Have at least two
Forest One or more domains that trust each other
OU (organizational unit) A folder for objects, used to delegate admin rights and link Group Policy
User / computer object An account that can sign in
Group A list of members used to give permissions

OU vs group confuses everyone at first:

  • An OU decides where an object lives – and therefore which Group Policies apply and who can manage it.
  • A group decides what its members can access. One user is in one OU, but can be in many groups.
Active Directory structure: forest, domain, domain controllers, OUs, users, groups and GPOs Forest: contoso.local Forest: contoso.local Domain: contoso.local One database of users, computers and policies Domain: contoso.local Users, computers, policies – ஒரே database DC01 Domain Controller DC01 Domain Controller DC02 Domain Controller DC02 Domain Controller DCs replicate the same data DC-கள் ஒரே data-வை replicate செய்கின்றன Organizational Units (OUs) OU-கள் (folders போல) OU: Servers OU: Servers OU: Staff OU: Staff SRV01 SRV01 SRV02 SRV02 User: priya User: priya member of உறுப்பினர் Group: GG-Server-Admins Give rights to groups, not single users Group: GG-Server-Admins தனி user-க்கு அல்ல, group-க்கு rights GPO linked to an OU Its settings flow down to everything inside OU-உடன் link செய்த GPO உள்ளே உள்ள எல்லாவற்றுக்கும்settings பொருந்தும்
A forest holds one or more domains. Domain controllers share the database; OUs organise objects so you can delegate and link GPOs.ஒரு forest-ல் domains இருக்கும். DC-கள் database-ஐ பகிர்கின்றன; OU-கள் objects-ஐ ஒழுங்குபடுத்தி, delegation மற்றும் GPO link செய்ய உதவுகின்றன.

Group types and scopes

  • Security groups give permissions. Distribution groups are only for email lists.
  • Scope, simplified: use Global groups for people (e.g. GG-Finance-Users) and Domain Local groups for permissions on a resource (e.g. DL-FinanceShare-Read). Put the global group inside the domain local group, and give the domain local group the permission. This pattern (often called AGDLP) keeps permissions tidy as the company grows.

Tools

  • Active Directory Users and Computers (dsa.msc) – the classic console
  • Active Directory Administrative Center – newer, shows the PowerShell it runs
  • PowerShell ActiveDirectory module – part of RSAT; on a DC it’s already installed
Import-Module ActiveDirectory
Get-ADDomain | Select-Object Name, DNSRoot, PDCEmulator

Everyday tasks in PowerShell

Find a user:

Get-ADUser -Identity jdoe -Properties LockedOut, PasswordLastSet, LastLogonDate, Enabled
Get-ADUser -Filter "Surname -eq 'Doe'" | Select-Object Name, SamAccountName

Create a user (prompts for the password, so it never appears in your script or history):

New-ADUser -Name 'Jane Doe' -GivenName Jane -Surname Doe `
    -SamAccountName jdoe -UserPrincipalName jdoe@contoso.local `
    -Path 'OU=Users,OU=Lab,DC=contoso,DC=local' `
    -AccountPassword (Read-Host 'Initial password' -AsSecureString) `
    -ChangePasswordAtLogon $true -Enabled $true

Unlock and reset:

Unlock-ADAccount -Identity jdoe
Set-ADAccountPassword -Identity jdoe -Reset -NewPassword (Read-Host 'New password' -AsSecureString)
Set-ADUser -Identity jdoe -ChangePasswordAtLogon $true

Groups:

Add-ADGroupMember -Identity 'GG-Finance-Users' -Members jdoe
Get-ADPrincipalGroupMembership -Identity jdoe | Select-Object Name
Get-ADGroupMember -Identity 'GG-Finance-Users' -Recursive | Select-Object Name

Disable a leaver (disable first, delete later – deleting can’t be undone easily):

Disable-ADAccount -Identity jdoe
Move-ADObject -Identity (Get-ADUser jdoe).DistinguishedName -TargetPath 'OU=Disabled,OU=Lab,DC=contoso,DC=local'

Useful reports

# Locked-out accounts right now
Search-ADAccount -LockedOut | Select-Object Name, SamAccountName

# Users who haven't signed in for 90 days
Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 -UsersOnly |
    Select-Object Name, LastLogonDate | Sort-Object LastLogonDate

LastLogonDate is replicated roughly every 9–14 days, so it’s good for “inactive for months”, not for “did they log in this morning”.

Good habits

  • Use separate admin accounts for admin work; never browse or read email as a domain admin.
  • Turn on the AD Recycle Bin (Enable-ADOptionalFeature) in your lab and at work if it’s off – it makes deleted objects recoverable.
  • Name groups consistently so their purpose is obvious from the name.
  • Make bulk changes with -WhatIf first.

FAQ

Why can’t a user log in even after I unlocked them? Check whether the account is disabled, expired, or the password must change at logon on a system that can’t prompt for it. Get-ADUser jdoe -Properties * shows all of these.

Should I delete users when they leave? Disable and move them first, keep them for an agreed period, then delete. That keeps file ownership and audit trails readable.

What’s next

Next: DNS and DHCP essentials – AD can’t work without DNS.

Practise this topic

Test yourself with free questions on this topic – instant answers and explanations.

Start practice questions

Active DirectoryWindows ServerPowerShellBeginnerIdentity

Gopinath Karthikeyan

Gopinath Karthikeyan – Windows Site Reliability Engineer with about 12 years in enterprise Windows Server infrastructure, and founder of WinOps Academy. YouTube · LinkedIn

More in Windows Server