Step-by-step lab: creating users, OUs, security groups, and group memberships using PowerShell
Managing users and groups manually through graphical tools can be time-consuming and error-prone in enterprise environments. PowerShell provides a fast, consistent, and repeatable way to manage Active Directory, making it a core skill for system administrators.
In this hands-on lab, I demonstrate how to automate common Active Directory tasks using PowerShell, including
-
Creating a new AD user
-
Placing the user in a specific Organizational Unit (OU)
-
Creating a new Security Group in a designated OU
-
Adding the user to the Security Group
This tutorial shows how these tasks are performed in real enterprise environments and is a great starting point for automating identity and access management.
🎥 Video Walkthrough
Lab Prerequisites
-
Domain-joined Windows Server
-
Active Directory Domain Services installed
-
PowerShell running with appropriate privileges
-
RSAT / ActiveDirectory PowerShell module available
Prerequisite (Run Once)
Ensure the Active Directory module is available:
Run:
Import-Module ActiveDirectory
If this fails, install RSAT / AD DS tools on the server.
Step‑by‑Step PowerShell Implementation
Step 1: Create a New Active Directory User Using PowerShell
Objective: Automate user creation instead of using Active Directory Users and Computers (ADUC).
-
Define user properties (name, username, password)
-
Specify the target OU
-
Enables the account immediately
PowerShell Command
New-ADUser `
-Name "John Doe" `
-GivenName "John" `
-Surname "Doe" `
-SamAccountName "jdoe" `
-UserPrincipalName "jdoe@humbletech.local" `
-Path "OU=Users,OU=HumbleTech,DC=humbletech,DC=local" `
-AccountPassword (ConvertTo-SecureString "P@ssw0rd123!" -AsPlainText -Force) `
-Enabled $true
✅ Result: A new user account is created directly in the correct OU.
Step 2: Assign the User to a Specific Organizational Unit (OU)
Objective: Maintain directory structure and delegation boundaries.
-
Target a predefined OU
-
Ensure proper placement for GPO application and administrative control
If the user already exists and needs to be moved:
Move-ADObject `
-Identity "CN=John Doe,CN=Users,DC=humbletech,DC=local" `
-TargetPath "OU=Users,OU=HumbleTech,DC=humbletech,DC=local"
Alternative (recommended): verify OU placement
Get-ADUser jdoe | Select-Object DistinguishedName
Step 3: Create a New Security Group Under a Designated OU
Objective: Automate group creation for role-based access control.
-
Define group name and scope
-
Create the group under a specific OU
PowerShell Command
New-ADGroup `
-Name "HR-Security-Group" `
-SamAccountName "HR-Sec-Group" `
-GroupCategory Security `
-GroupScope Global `
-Path "OU=Groups,OU=HumbleTech,DC=humbletech,DC=local" `
-Description “Security group for HR users”
Notes
-
Security group (not distribution)
-
Global scope (best practice for permissions)
-
Created directly inside the Groups OU
Step 4: Add the User to the Security Group
Objective: Grant access through group membership instead of direct permissions.
-
Add user to security group
-
Verify membership
PowerShell Command
Add-ADGroupMember `
-Identity "HR-Security-Group" `
-Members jdoe
Verify Membership
Get-ADGroupMember "HR-Security-Group"
Optional Verification Commands
Confirm User Exists
Get-ADUser jdoe
Confirm Group Exists
Get-ADGroup "HR-Security-Group"
Confirm User’s Group Membership
Get-ADPrincipalGroupMembership jdoe | Select Name
Pro Tip
In enterprise environments, permissions should always be assigned to groups, not users directly.
This PowerShell-driven approach enforces role-based access control (RBAC) and scales cleanly.
Why This Matters in Enterprise Environments
Automating Active Directory tasks with PowerShell:
-
Reduces human error
-
Improves consistency
-
Saves administrative time
-
Scales across hundreds or thousands of users
-
Forms the foundation for advanced automation and DevOps workflows
Key Takeaway
PowerShell is an essential tool for modern IT administrators. Even basic automation like user and group management delivers immediate operational value and sets the stage for more advanced infrastructure automation.
Discover more from Humble Cloud Tech
Subscribe to get the latest posts sent to your email.



