Bird
0
0

Given the CSV file 'users.csv' with columns 'Username' and 'Email', what will this script output?

medium📝 Command Output Q4 of 15
PowerShell - Active Directory
Given the CSV file 'users.csv' with columns 'Username' and 'Email', what will this script output?
Import-Csv users.csv | ForEach-Object { "User: $($_.Username), Email: $($_.Email)" }
AAn error because of incorrect variable usage
BNothing, the script does not output anything
COnly the usernames without emails
DA list of strings showing each user's username and email
Step-by-Step Solution
Solution:
  1. Step 1: Understand Import-Csv and ForEach-Object usage

    Import-Csv reads CSV rows as objects; ForEach-Object processes each object.
  2. Step 2: Analyze the string interpolation

    "User: $($_.Username), Email: $($_.Email)" creates a formatted string for each user.
  3. Final Answer:

    A list of strings showing each user's username and email -> Option D
  4. Quick Check:

    Output format = formatted user info strings [OK]
Quick Trick: Use $($_.Property) inside strings to insert CSV data [OK]
Common Mistakes:
  • Expecting an error due to variable syntax
  • Thinking only usernames print without emails
  • Assuming no output without explicit Write-Output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes