Challenge - 5 Problems
Get-ADUser Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Get-ADUser command?
Consider the following PowerShell command to get a user named 'jdoe' from Active Directory:
What will this command output if the user 'jdoe' exists and has the email 'jdoe@example.com'?
Get-ADUser -Identity jdoe -Properties EmailAddress | Select-Object Name, EmailAddressWhat will this command output if the user 'jdoe' exists and has the email 'jdoe@example.com'?
PowerShell
Get-ADUser -Identity jdoe -Properties EmailAddress | Select-Object Name, EmailAddress
Attempts:
2 left
💡 Hint
The command uses Select-Object to show both Name and EmailAddress properties.
✗ Incorrect
The command retrieves the user 'jdoe' including the EmailAddress property, then selects and displays both Name and EmailAddress. So the output shows both fields with their values.
📝 Syntax
intermediate2:00remaining
Which Get-ADUser command syntax correctly retrieves users with 'Manager' property?
You want to get all users and include their 'Manager' property in the output. Which of these commands is syntactically correct?
Attempts:
2 left
💡 Hint
The parameter to include extra properties is '-Properties' followed by property names.
✗ Incorrect
The correct parameter is '-Properties' (plural) followed by the property name without quotes. Option D uses correct syntax.
🔧 Debug
advanced2:00remaining
What error does this Get-ADUser command produce?
Analyze this command:
What error will PowerShell show when running this?
Get-ADUser -Filter {Name -eq 'jdoe' -and Enabled -eq $true} -Properties EmailAddress | Select Name, EmailAddressWhat error will PowerShell show when running this?
Attempts:
2 left
💡 Hint
The filter syntax uses script block {} but Get-ADUser expects a string filter.
✗ Incorrect
Get-ADUser expects the -Filter parameter as a string, not a script block. Using {} causes PowerShell to misinterpret the filter and throw a positional parameter error.
🚀 Application
advanced2:00remaining
How many users will this command return?
What is the number of users returned by this command?
Assuming the Active Directory has 1000 users, 200 are disabled, and 50 of those disabled have last logon date older than 90 days.
Get-ADUser -Filter "Enabled -eq $false" -Properties LastLogonDate | Where-Object { $_.LastLogonDate -lt (Get-Date).AddDays(-90) }Assuming the Active Directory has 1000 users, 200 are disabled, and 50 of those disabled have last logon date older than 90 days.
PowerShell
Get-ADUser -Filter "Enabled -eq $false" -Properties LastLogonDate | Where-Object { $_.LastLogonDate -lt (Get-Date).AddDays(-90) }
Attempts:
2 left
💡 Hint
The command filters disabled users, then filters those with last logon older than 90 days.
✗ Incorrect
The command first gets 200 disabled users, then filters those with LastLogonDate older than 90 days, which is 50 users.
🧠 Conceptual
expert2:00remaining
What is the value of variable $userCount after running this script?
Given this PowerShell script:
If Active Directory has 500 users, 120 of which have Department set to 'Sales', what is the value of $userCount?
$users = Get-ADUser -Filter * -Properties Department | Where-Object { $_.Department -eq 'Sales' }
$userCount = $users.CountIf Active Directory has 500 users, 120 of which have Department set to 'Sales', what is the value of $userCount?
Attempts:
2 left
💡 Hint
Count property returns the number of items in the collection.
✗ Incorrect
The script filters users with Department 'Sales' and stores them in $users. $userCount is the number of those users, which is 120.