PowerShell Genie

🟠 Break/Fix Challenge 1 · Intermediate · ~25 minutes

The Broken Report

🎫 Task Ticket #TASK-3117

Reported by
Operations (morning dashboard review)
Priority
Medium
Summary
The scheduled task NightlyServiceReport runs C:\Scripts\service-report.ps1 at 02:00 every night. For 3 days the output CSV has contained headers but zero data rows. The morning dashboard also shows a blank "Print service" status.
Your task
Read the broken script, identify the bugs, test your hypotheses in the terminal, submit the corrected script, and prove the fix works.

Simulated environment — fictional server and data. The terminal below runs the same fictional dataset the nightly script sees. No real systems affected.

📄 The broken script (as found on the server)

# Service Health Report — nightly via scheduled task "NightlyServiceReport" (02:00)
# Output: C:\Reports\service-health.csv

# Step 1: Collect services that need attention
$services = Get-Service | Where-Object { $_.Status -eq "Running" }

# Step 2: Keep only stopped services for the report
$attention = $services | Where-Object { $_.Status -eq "Stopped" }

# Step 3: Build the report rows
$report = $attention | Select-Object Name, Status, StartType

# Step 4: Tag the report with the print service name (used by the morning dashboard)
$printSvc = Get-Service | Where-Object { $_.Name -eq "PrintService" }
$printName = $printSvc.Name

# Step 5: Export the report
$report | Export-Csv -Path "C:\Reports\service-health.csv" -NoTypeInformation
Write-Output "Report written. Print service: $printName"

Test Terminal

Simulated PowerShell session with the same fictional data the script sees. Test the script's lines here before you fix them.

PS>

💡 Stuck? Progressive hints

No penalty for using hints. Finding the bug yourself teaches more — but a nudge beats staring at the screen.

🔧 Submit your fix

Edit the script below — fix both bugs — then test it. The verifier runs your script against the fictional data and checks that the report actually contains the stopped services and the print-service name resolves.

Genie guideThe Broken Report

Simulated environment — fictional server and data. The terminal below runs the same fictional dataset the nightly script sees. No real systems affected.