0
0
PowerShellscripting~10 mins

New-ADUser and Set-ADUser in PowerShell - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - New-ADUser and Set-ADUser
Start
Run New-ADUser
User Created in AD
Run Set-ADUser
User Properties Updated
End
First, a new user is created with New-ADUser. Then, Set-ADUser updates properties of that user.
Execution Sample
PowerShell
New-ADUser -Name "John Doe" -SamAccountName "jdoe" -AccountPassword (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force) -Enabled $true
Set-ADUser -Identity "jdoe" -Title "Developer"
Creates a new Active Directory user named John Doe, then sets his job title to Developer.
Execution Table
StepCommandActionResultOutput
1New-ADUser -Name "John Doe" -SamAccountName "jdoe" -AccountPassword ... -Enabled $trueCreate user objectUser 'jdoe' created in ADNo output if successful
2Set-ADUser -Identity "jdoe" -Title "Developer"Update user propertyUser 'jdoe' title set to 'Developer'No output if successful
3Verify userGet user infoUser 'jdoe' has Title 'Developer'Name: John Doe SamAccountName: jdoe Title: Developer
4EndNo more commandsProcess completeProcess finished successfully
💡 All commands executed successfully; user created and updated.
Variable Tracker
VariableStartAfter Step 1After Step 2Final
UserObjectnull{Name: John Doe, SamAccountName: jdoe, Enabled: True}{Name: John Doe, SamAccountName: jdoe, Enabled: True, Title: Developer}{Name: John Doe, SamAccountName: jdoe, Enabled: True, Title: Developer}
Key Moments - 3 Insights
Why does New-ADUser not show output after creating the user?
New-ADUser by default does not return output on success, so the execution_table row 1 shows 'No output if successful'. You can add -PassThru to get output.
Can Set-ADUser create a user if it does not exist?
No, Set-ADUser only updates existing users. The execution_table shows New-ADUser must run first to create the user.
How do we verify the user properties after updates?
You can run Get-ADUser to check properties. The execution_table row 3 shows verifying user info after updates.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the user Title after Step 1?
ANo Title set
BDeveloper
CAdministrator
DUser
💡 Hint
Check the 'Result' column in Step 1 and Step 2 in execution_table.
At which step does the user get the Title 'Developer'?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at the 'Action' and 'Result' columns in execution_table for Step 2.
If you skip New-ADUser and run only Set-ADUser, what happens?
AUser is created automatically
BError: user not found
CUser properties updated anyway
DNo effect, command ignored
💡 Hint
Refer to key_moments about Set-ADUser requiring existing user.
Concept Snapshot
New-ADUser creates a new Active Directory user.
Set-ADUser updates properties of an existing user.
New-ADUser needs password and enabled status.
Set-ADUser requires the user identity.
Use Get-ADUser to verify changes.
No output shown if commands succeed by default.
Full Transcript
This visual execution shows how New-ADUser creates a user named John Doe with username jdoe and a password. Then Set-ADUser updates the Title property to Developer. The execution table traces each step, showing commands run, actions taken, and results. Variables track the user object state after each step. Key moments clarify why New-ADUser does not output by default, that Set-ADUser cannot create users, and how to verify changes. The quiz tests understanding of when properties are set and command dependencies. The snapshot summarizes the commands and usage rules.