Skip to content

DevOps · updated 26 November 2026

PowerShell automates Windows and cloud administration. These scenarios cover the object pipeline, errors and safe automation.

Top 10 PowerShell scenario questions

Try each one yourself first, then open the model answer.

1. A try/catch does not catch a failing cmdlet. Why?

Show answer

Many errors are non-terminating. Add -ErrorAction Stop or set $ErrorActionPreference to Stop in the script.

2. Filtering after retrieving every user is slow. What do you change?

Show answer

Filter at the source with the cmdlet's -Filter parameter rather than Where-Object afterwards.

3. A script that deletes accounts must be safe to test. How?

Show answer

Support -WhatIf and -Confirm with SupportsShouldProcess, log actions and test on a small group first.

4. A function returns extra unexpected values. What is the cause?

Show answer

Any uncaptured output goes to the pipeline. Assign to $null or cast to [void] for output you do not want.

5. Credentials are hard-coded in a script. What is better?

Show answer

Use a secret store, managed identities or Get-Credential for interactive use, and never commit secrets.

6. You need to run the same task on 200 servers. How?

Show answer

Use Invoke-Command with several computers, control concurrency with ThrottleLimit and collect errors per machine.

7. Comparing a collection with -eq returns items instead of true or false. Why?

Show answer

With a collection on the left, comparison operators filter it. Use -contains or -in for membership tests.

8. A CSV export shows only type names for a property. What happened?

Show answer

The property holds an object or array. Select a calculated property that turns it into text.

9. A script works in PowerShell 7 but not Windows PowerShell 5.1. What do you check?

Show answer

Newer operators and parameters, default encodings and module compatibility. Declare the required version with #Requires.

10. How do you make a scheduled script easy to troubleshoot?

Show answer

Use a transcript or structured logging, return meaningful exit codes and alert on failure.

Ready to build something great?

Book your free 30-minute consultation today. No obligation, just honest advice.