Bird
0
0

You want to create a new user 'mjohnson' with the display name 'Mary Johnson' and then immediately set her office location to 'HQ-5'. Which sequence of commands correctly achieves this?

hard📝 Application Q15 of 15
PowerShell - Active Directory
You want to create a new user 'mjohnson' with the display name 'Mary Johnson' and then immediately set her office location to 'HQ-5'. Which sequence of commands correctly achieves this?
ANew-ADUser -SamAccountName 'mjohnson' -DisplayName 'Mary Johnson' Set-ADUser -Identity 'mjohnson' -Office 'HQ-5'
BSet-ADUser -SamAccountName 'mjohnson' -DisplayName 'Mary Johnson' New-ADUser -Identity 'mjohnson' -Office 'HQ-5'
CNew-ADUser -UserName 'mjohnson' -Name 'Mary Johnson' -Office 'HQ-5' -Enabled $true
DNew-ADUser -SamAccountName 'mjohnson' -DisplayName 'Mary Johnson' -Office 'HQ-5' -Enabled $true
Step-by-Step Solution
Solution:
  1. Step 1: Create user with New-ADUser

    Use -SamAccountName and -DisplayName to create the user. Office location is not set here.
  2. Step 2: Update office location with Set-ADUser

    Use Set-ADUser -Identity 'mjohnson' -Office 'HQ-5' to set the office property after creation.
  3. Step 3: Evaluate other options

    Set-ADUser -SamAccountName 'mjohnson' -DisplayName 'Mary Johnson' New-ADUser -Identity 'mjohnson' -Office 'HQ-5' tries to update before creation, which fails. New-ADUser -UserName 'mjohnson' -Name 'Mary Johnson' -Office 'HQ-5' -Enabled $true uses wrong parameters. New-ADUser -SamAccountName 'mjohnson' -DisplayName 'Mary Johnson' -Office 'HQ-5' -Enabled $true fails because -Enabled $true requires -AccountPassword (e.g., (ConvertTo-SecureString 'P@ssw0rd' -AsPlainText -Force)), which is missing.
  4. Final Answer:

    New-ADUser -SamAccountName 'mjohnson' -DisplayName 'Mary Johnson' Set-ADUser -Identity 'mjohnson' -Office 'HQ-5' -> Option A
  5. Quick Check:

    Create then update properties = B [OK]
Quick Trick: Create user first, then update extra properties with Set-ADUser [OK]
Common Mistakes:
  • Trying to set unsupported properties in New-ADUser
  • Running Set-ADUser before user exists
  • Using wrong parameter names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes