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.
Jump into concepts and practice - no test required
New-ADUser -Name "John Doe" -SamAccountName "jdoe" -AccountPassword (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force) -Enabled $true Set-ADUser -Identity "jdoe" -Title "Developer"
| Step | Command | Action | Result | Output |
|---|---|---|---|---|
| 1 | New-ADUser -Name "John Doe" -SamAccountName "jdoe" -AccountPassword ... -Enabled $true | Create user object | User 'jdoe' created in AD | No output if successful |
| 2 | Set-ADUser -Identity "jdoe" -Title "Developer" | Update user property | User 'jdoe' title set to 'Developer' | No output if successful |
| 3 | Verify user | Get user info | User 'jdoe' has Title 'Developer' | Name: John Doe SamAccountName: jdoe Title: Developer |
| 4 | End | No more commands | Process complete | Process finished successfully |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| UserObject | null | {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} |
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.
New-ADUser cmdlet in PowerShell?New-ADUser is designed to create new user accounts in Active Directory.Remove-ADUser, Set-ADAccountPassword, or Get-ADUser.New-ADUser?-SamAccountName, and for display name is -DisplayName.-SamAccountName 'jdoe' and -DisplayName 'John Doe', which is correct syntax.New-ADUser -SamAccountName 'asmith' -Name 'Alice Smith' -AccountPassword (ConvertTo-SecureString 'P@ssw0rd' -AsPlainText -Force) -Enabled $true Set-ADUser -Identity 'asmith' -Title 'Manager'
Set-ADUser command sets the Title property to 'Manager' for user 'asmith'.Set-ADUser -Identity 'bwhite' -Department 'Sales'
-SamAccountName and -DisplayName to create the user. Office location is not set here.Set-ADUser -Identity 'mjohnson' -Office 'HQ-5' to set the office property after creation.