0
0
PowerShellscripting~20 mins

Get-ADUser in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Get-ADUser Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Get-ADUser command?
Consider the following PowerShell command to get a user named 'jdoe' from Active Directory:

Get-ADUser -Identity jdoe -Properties EmailAddress | Select-Object Name, EmailAddress

What 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
A
Name       EmailAddress
----       ------------
Error: Property 'EmailAddress' not found
B
Name       EmailAddress
----       ------------
jdoe       jdoe@example.com
C
EmailAddress
------------
jdoe@example.com
D
Name
----
jdoe
Attempts:
2 left
💡 Hint
The command uses Select-Object to show both Name and EmailAddress properties.
📝 Syntax
intermediate
2: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?
AGet-ADUser -Filter * -PropertiesManager
BGet-ADUser -Filter * -Property Manager
CGet-ADUser -Filter * -Properties 'Manager'
DGet-ADUser -Filter * -Properties Manager
Attempts:
2 left
💡 Hint
The parameter to include extra properties is '-Properties' followed by property names.
🔧 Debug
advanced
2:00remaining
What error does this Get-ADUser command produce?
Analyze this command:

Get-ADUser -Filter {Name -eq 'jdoe' -and Enabled -eq $true} -Properties EmailAddress | Select Name, EmailAddress

What error will PowerShell show when running this?
AGet-ADUser : A positional parameter cannot be found that accepts argument '-and'.
BGet-ADUser : The term 'Enabled' is not recognized as a cmdlet.
CNo error, command runs successfully.
DGet-ADUser : Property 'EmailAddress' does not exist.
Attempts:
2 left
💡 Hint
The filter syntax uses script block {} but Get-ADUser expects a string filter.
🚀 Application
advanced
2:00remaining
How many users will this command return?
What is the number of users returned by this command?

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) }
A1000
B200
C50
D0
Attempts:
2 left
💡 Hint
The command filters disabled users, then filters those with last logon older than 90 days.
🧠 Conceptual
expert
2:00remaining
What is the value of variable $userCount after running this script?
Given this PowerShell script:

$users = Get-ADUser -Filter * -Properties Department | Where-Object { $_.Department -eq 'Sales' }
$userCount = $users.Count


If Active Directory has 500 users, 120 of which have Department set to 'Sales', what is the value of $userCount?
A120
B500
C0
Dnull
Attempts:
2 left
💡 Hint
Count property returns the number of items in the collection.