0
0
PowerShellscripting~20 mins

Bulk user operations from CSV in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bulk User Operations Master
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 PowerShell script reading a CSV?
Given a CSV file named users.csv with the following content:
Username,Email
alice,alice@example.com
bob,bob@example.com

What will this script output?
Import-Csv users.csv | ForEach-Object { "User: $($_.Username), Email: $($_.Email)" }
PowerShell
Import-Csv users.csv | ForEach-Object { "User: $($_.Username), Email: $($_.Email)" }
A
User: alice, Email: alice@example.com
User: bob, Email: bob@example.com
B
Username,Email
alice,alice@example.com
bob,bob@example.com
C
User: $_.Username, Email: $_.Email
User: $_.Username, Email: $_.Email
DError: Cannot find path 'users.csv' because it does not exist.
Attempts:
2 left
💡 Hint
Think about how Import-Csv creates objects and how ForEach-Object accesses properties.
📝 Syntax
intermediate
2:00remaining
Which option correctly updates user emails from CSV in PowerShell?
You want to update user emails in Active Directory from a CSV file with columns Username and NewEmail. Which script snippet correctly updates the email attribute for each user?
AImport-Csv users.csv | ForEach-Object { Set-ADUser -Identity $_.Username -Email $_.NewEmail }
BImport-Csv users.csv | ForEach-Object { Set-ADUser -Identity $Username -EmailAddress $NewEmail }
CImport-Csv users.csv | ForEach-Object { Set-ADUser -Identity $_.Username -EmailAddress $_.NewEmail }
DImport-Csv users.csv | ForEach-Object { Set-ADUser -User $_.Username -EmailAddress $_.NewEmail }
Attempts:
2 left
💡 Hint
Check the parameter names for Set-ADUser and how to access CSV properties.
🔧 Debug
advanced
2:00remaining
Why does this bulk user creation script fail?
This script is intended to create users from a CSV file with Username and Password columns:
Import-Csv users.csv | ForEach-Object {
  New-ADUser -Name $_.Username -AccountPassword (ConvertTo-SecureString $_.Password) -Enabled $true
}

What is the cause of the error?
PowerShell
Import-Csv users.csv | ForEach-Object {
  New-ADUser -Name $_.Username -AccountPassword (ConvertTo-SecureString $_.Password) -Enabled $true
}
AImport-Csv cannot read the CSV file without specifying the delimiter.
BNew-ADUser does not accept -AccountPassword parameter.
CThe script is missing a pipeline to export the created users.
DConvertTo-SecureString requires the -AsPlainText and -Force flags to convert plain text passwords.
Attempts:
2 left
💡 Hint
Think about how ConvertTo-SecureString handles plain text input.
🚀 Application
advanced
2:00remaining
How to safely disable multiple users from a CSV list?
You have a CSV file with a list of usernames to disable in Active Directory. Which script snippet safely disables these users and logs each action to a file named disable_log.txt?
A
Import-Csv users.csv | ForEach-Object {
  Disable-ADAccount -Identity $_.Username
  Add-Content -Path disable_log.txt -Value "Disabled user: $($_.Username)"
}
B
Import-Csv users.csv | ForEach-Object {
  Disable-ADAccount $_.Username
  Out-File disable_log.txt -InputObject "Disabled user: $_.Username"
}
C
Import-Csv users.csv | ForEach-Object {
  Disable-ADAccount -Identity $_.Username | Out-File disable_log.txt
}
D
Import-Csv users.csv | ForEach-Object {
  Disable-ADAccount -User $_.Username
  Add-Content disable_log.txt "Disabled user: $_.Username"
}
Attempts:
2 left
💡 Hint
Check the correct parameter names and how to append text to a file.
🧠 Conceptual
expert
2:00remaining
What is the main benefit of using Import-Csv with pipeline in bulk user operations?
Why is using Import-Csv piped into ForEach-Object a preferred method for bulk user operations in PowerShell?
AIt runs all user operations in parallel to speed up execution.
BIt allows processing each user record as an object, enabling property access and command chaining efficiently.
CIt automatically validates user data and prevents errors during bulk operations.
DIt converts CSV data into XML format for better compatibility with Active Directory.
Attempts:
2 left
💡 Hint
Think about how PowerShell treats CSV data and pipelines.