0
0
PowerShellscripting~10 mins

Get-ADUser in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get all users from Active Directory.

PowerShell
Get-ADUser [1]
Drag options to blanks, or click blank then click option'
A-AllUsers
B-Name *
C-Filter *
D-List *
Attempts:
3 left
💡 Hint
Common Mistakes
Using -Name * which is not a valid parameter for listing all users.
Using -AllUsers which does not exist.
Using -List * which is invalid.
2fill in blank
medium

Complete the code to get a user with the username 'jdoe'.

PowerShell
Get-ADUser -Identity [1]
Drag options to blanks, or click blank then click option'
Auser1
BJohn Doe
CJDoe123
Djdoe
Attempts:
3 left
💡 Hint
Common Mistakes
Using the full name instead of username.
Using an incorrect username.
3fill in blank
hard

Fix the error in the code to get users with the last name 'Smith'.

PowerShell
Get-ADUser -Filter "[1]"
Drag options to blanks, or click blank then click option'
ASurname -eq 'Smith'
BLast -eq 'Smith'
CLastName -eq 'Smith'
DName -eq 'Smith'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'LastName' which is not a valid property.
Using 'Name' which is the full name, not last name.
4fill in blank
hard

Fill both blanks to get users whose account is enabled and have 'Admin' in their title.

PowerShell
Get-ADUser -Filter "Enabled -eq [1] -and Title -like '[2]'"
Drag options to blanks, or click blank then click option'
ATrue
BFalse
C*Admin*
DAdmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'False' for enabled accounts.
Not using wildcards for partial title match.
5fill in blank
hard

Fill all three blanks to create a dictionary of usernames and their email addresses for users in the 'Sales' department.

PowerShell
$users = Get-ADUser -Filter "Department -eq '[1]'" -Properties [2]
$userEmails = @{ }
[3]
Drag options to blanks, or click blank then click option'
ASales
BEmailAddress
Cforeach ($u in $users) { $u.SamAccountName = $u.EmailAddress }
Dforeach ($u in $users) { $userEmails[$u.SamAccountName] = $u.EmailAddress }
Attempts:
3 left
💡 Hint
Common Mistakes
Not requesting the EmailAddress property, so emails are missing.
Incorrect loop syntax or assignment inside the loop.
Using wrong department name.