Applies to: Windows Server 2019, 2022 and 2025.
Scripted provisioning improves consistency when identity data, password delivery, OU placement and group approvals are controlled.
Active Directory changes affect authentication across the environment. Use tested backups, separate privileged accounts and a maintenance plan. See managed Windows VPS hosting for managed Windows VPS services.
Prerequisites
- Confirm unique UPN and sAMAccountName values.
- Choose the correct OU.
- Deliver temporary passwords through an approved channel.
- Assign least privilege separately.
Procedure
Step 1: Prompt for password
Never embed it in a script.
$password=Read-Host 'Enter temporary password' -AsSecureStringStep 2: Create the account
Replace example identity values.
New-ADUser -Name 'Alex Morgan' -GivenName 'Alex' -Surname 'Morgan' -SamAccountName 'amorgan' -UserPrincipalName 'amorgan@corp.example' -Path 'OU=Users,DC=corp,DC=example' -AccountPassword $password -Enabled $true -ChangePasswordAtLogon $trueStep 3: Set approved attributes
Use the authoritative HR or identity source.
Step 4: Assign role groups
Add only after owner approval.
Step 5: Test policies
Confirm sign-in without administrative rights.
Verification
Review enabled state and memberships.
Get-ADUser amorgan -Properties Enabled,PasswordLastSet,MemberOf | Select SamAccountName,UserPrincipalName,Enabled,PasswordLastSet,MemberOfRollback and recovery
Disable first when provisioning is wrong. Delete only after dependent files, mailbox and workflows are addressed.
Operational notes
Bulk scripts should validate source data, support WhatIf and log results without passwords.
Official references
For a hosted environment with setup and onboarding, explore our managed Windows VPS plans.
How to Create a New Active Directory Forest with PowerShell
How to Create a New Active Directory Forest with PowerShellApplies to: Windows Server 2019, 2022 and 2025.This procedure promotes the first…
How to Add an Additional Domain Controller to an Existing Domain
How to Add an Additional Domain Controller to an Existing DomainApplies to: Windows Server 2019, 2022 and 2025.A second controller improves…
How to Create Organizational Units and Protect Them from Accidental Deletion
How to Create Organizational Units and Protect Them from Accidental DeletionApplies to: Windows Server 2019, 2022 and 2025.OUs should…
How to Design Active Directory Security Groups with AGDLP
How to Design Active Directory Security Groups with AGDLPApplies to: Windows Server 2019, 2022 and 2025.AGDLP separates people from…
How to Enable Active Directory Recycle Bin
How to Enable Active Directory Recycle BinApplies to: Windows Server 2019, 2022 and 2025.Recycle Bin preserves deleted-object attributes…