0
0
PowerShellscripting~20 mins

Report generation automation in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Report Automation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of CSV report generation script
What is the output of this PowerShell script that generates a CSV report from a list of users?
PowerShell
 $users = @(
    @{Name='Alice'; Age=30; Department='HR'},
    @{Name='Bob'; Age=25; Department='IT'},
    @{Name='Charlie'; Age=35; Department='Finance'}
)
$users | Export-Csv -Path 'report.csv' -NoTypeInformation
Get-Content 'report.csv' | Select-Object -First 3
A
"\"Name\",\"Age\",\"Department\""
"\"Alice\",30,\"HR\""
"\"Bob\",25,\"IT\""
B
Name,Age,Department
Alice,30,HR
Bob,25,IT
C
Name Age Department
Alice 30 HR
Bob 25 IT
D
"Name,Age,Department"
"Alice,30,HR"
"Bob,25,IT"
Attempts:
2 left
💡 Hint
Think about how Export-Csv formats the output with quotes and commas.
📝 Syntax
intermediate
2:00remaining
Correct syntax for filtering report data
Which option correctly filters a list of processes to include only those with CPU usage greater than 10 and exports to a CSV report?
AGet-Process | Filter-Object { $_.CPU > 10 } | Export-Csv -Path 'high_cpu.csv' -NoTypeInformation
BGet-Process | Where { CPU > 10 } | Export-Csv 'high_cpu.csv' -NoTypeInformation
CGet-Process | Where-Object CPU -gt 10 | Export-Csv -Path 'high_cpu.csv'
DGet-Process | Where-Object { $_.CPU -gt 10 } | Export-Csv -Path 'high_cpu.csv' -NoTypeInformation
Attempts:
2 left
💡 Hint
Remember the correct cmdlet and syntax for filtering objects in PowerShell.
🔧 Debug
advanced
2:00remaining
Identify the error in report generation script
What error will this script produce when run, and why? $services = Get-Service $services | Where-Object Status -eq 'Running' | Export-Csv -Path 'running_services.csv' -NoTypeInformation
PowerShell
$services = Get-Service
$services | Where-Object Status -eq 'Running' | Export-Csv -Path 'running_services.csv' -NoTypeInformation
ATypeError: Cannot compare Status property directly without script block
BNo error, script runs and exports running services
CSyntaxError: Missing script block in Where-Object
DRuntimeError: Export-Csv path not found
Attempts:
2 left
💡 Hint
Check the syntax of Where-Object usage.
🚀 Application
advanced
2:00remaining
Automate report generation with date-stamped filename
Which script correctly generates a report of disk usage and saves it with a filename including the current date in YYYY-MM-DD format?
A
$date = Get-Date -Format 'yyyy-MM-dd'
Get-PSDrive -PSProvider FileSystem | Select-Object Name,Free,Used | Export-Csv -Path "disk_report_$date.csv" -NoTypeInformation
B
$date = Get-Date -Format 'dd-MM-yyyy'
Get-PSDrive -PSProvider FileSystem | Select Name,Free,Used | Export-Csv -Path "disk_report_$date.csv"
C
$date = Get-Date -Format 'yyyyMMdd'
Get-PSDrive -PSProvider FileSystem | Select-Object Name,Free,Used | Export-Csv -Path 'disk_report_$date.csv' -NoTypeInformation
D
$date = Get-Date -Format 'yyyy-MM-dd'
Get-PSDrive -PSProvider FileSystem | Select-Object Name,Free,Used | Export-Csv -Path 'disk_report_date.csv' -NoTypeInformation
Attempts:
2 left
💡 Hint
Check date format and variable interpolation in strings.
🧠 Conceptual
expert
2:00remaining
Understanding pipeline behavior in report automation
In a PowerShell script that generates a report, what happens if you place Export-Csv before filtering the data with Where-Object in the pipeline?
AThe script will fail with a pipeline error because Export-Csv must be last.
BThe CSV file will contain all data before filtering, so the report is not filtered.
CThe CSV file will be empty because Export-Csv clears the pipeline.
DThe filtering will still apply after Export-Csv, so the report is filtered correctly.
Attempts:
2 left
💡 Hint
Think about how pipelines process commands in order.