27 lines
1.2 KiB
PowerShell
27 lines
1.2 KiB
PowerShell
# THIS SCRIPT MUST BE RUN AS ADMINISTRATOR ON DC1
|
|
|
|
# Define new user parameters
|
|
$username = "Wormtongue" # Change this to the desired username
|
|
$Password = Read-Host -Prompt 'Enter Password' -AsSecureString
|
|
$userPrincipalName = $username + "Wormtongue@RohanIT.sec" # Change to your domain
|
|
$displayName = "Wormtongue" # Change this to the desired display name
|
|
$description = "SysAdm" # Change this to a suitable description
|
|
$path = "CN=Users,DC=<RohanIT>,DC=<sec>" # Change the path to the appropriate path in your AD structure
|
|
# My path in the video CN=Users,DC=InfraIT,DC=sec (CN stands for Common Name, and DC stands for Domain Component)
|
|
# Users is a container in the root of the domain and not a OU (Organizational Unit)
|
|
|
|
# Create the new user
|
|
New-ADUser -Name $displayName `
|
|
-GivenName $username `
|
|
-UserPrincipalName $userPrincipalName `
|
|
-SamAccountName $username `
|
|
-AccountPassword $password `
|
|
-DisplayName $displayName `
|
|
-Description $description `
|
|
-Path $path `
|
|
-Enabled $true
|
|
|
|
# Add the new user to the Domain Admins group
|
|
Add-ADGroupMember -Identity "Domain Admins" -Members $username
|
|
|
|
Write-Host "User $username created and added to Domain Admins group." |