Learn › Interview prep

PowerShell and Automation Interview Questions with Model Answers

PowerShell and automation interview questions with model answers: pipeline, remoting, error handling, credentials, idempotency and safe changes.

Intermediate 12 min read
By Gopinath Karthikeyan

Automation interviews check whether you can write scripts that are safe to run against production, not just scripts that work on your laptop. Here are the questions that come up most, with model answers.

PowerShell fundamentals

1. What’s the difference between PowerShell and cmd/Bash? PowerShell passes objects through the pipeline, not text. You can filter, sort and export by property (Where-Object Status -eq 'Running') without parsing text.

2. Where-Object vs -Filter – which is better? Use the cmdlet’s -Filter (or -Name) when available: it filters at the source (e.g. in AD or WMI) and returns less data. Where-Object filters after everything is retrieved – fine for small sets, slow for large ones.

3. Why shouldn’t you put Format-Table in the middle of a pipeline? Format-* cmdlets output formatting objects, not data. Use Select-Object for data; Format-* only at the very end for display.

4. Windows PowerShell 5.1 vs PowerShell 7? 5.1 ships with Windows and supports nearly all Windows admin modules. 7 is cross-platform, faster, actively developed, with features like ForEach-Object -Parallel. Many shops use both; some modules still need 5.1 (or the compatibility layer).

Remoting and scale

5. How do you run a command on 200 servers? Invoke-Command -ComputerName $servers -ScriptBlock {...} – runs in parallel (32 at a time by default, -ThrottleLimit to change), returns objects with PSComputerName. Capture failures with -ErrorVariable, report unreachable servers, and use sessions if running several commands. At larger scale or with change control, use Ansible/Jenkins.

6. Your remote command can’t access a file share. Why? The double hop: credentials used to reach server A aren’t passed on from A to the share on server B. Avoid the hop (copy from your machine, or run on the file server), or use approved delegation (resource-based Kerberos constrained delegation).

7. How do you pass a local variable into a remote script block? $using:variableName, or -ArgumentList with a param() block.

Reliability and safety

8. try/catch doesn’t catch my error. Why? Only terminating errors are caught. Many cmdlet errors are non-terminating; add -ErrorAction Stop (or set $ErrorActionPreference = 'Stop').

9. How do you make a script safe to run in production? Parameters with validation; SupportsShouldProcess for -WhatIf/-Confirm; report mode before change mode; per-server error handling; logging of every change; limits on scope (refuse “all servers” without -Force); tested in lab; reviewed through a pull request.

10. What does idempotent mean, and why does it matter? Running it again gives the same result without extra changes – it checks state before acting. It makes retries and scheduled runs safe. Ansible modules are idempotent by design; scripts must check first (“if not installed, install”).

11. How do you handle credentials in automation? Never in scripts or Git. Use the automation platform’s credential store (Jenkins Credentials, GitHub secrets, Ansible Vault), the SecretManagement module with a vault, or gMSAs for services. Pass secrets as environment variables or PSCredential objects; never log them.

12. How do you test PowerShell code? PSScriptAnalyzer for linting; Pester for unit tests (with Mock to fake cmdlets); integration tests in a lab; all run automatically on pull requests.

Tools and pipelines

13. When would you use Ansible instead of PowerShell remoting? For repeatable configuration across many servers with inventories, groups, variables, idempotent modules, check mode, rolling batches (serial) and consistent reporting. PowerShell does the work on the server; Ansible orchestrates where, when and in what order.

14. Walk me through an automation you built. (STAR) Pick one that saved real time or reduced risk. Describe the manual process, what you automated, the safety features (dry run, approvals, rollback), how it was adopted, and the measurable result. Keep client names and real server details out.

What’s next

Next: DevOps and CI/CD interview questions.

Practise this topic

Test yourself with free questions on this topic – instant answers and explanations.

Start practice questions

Interview PrepPowerShellAutomationIntermediate

Gopinath Karthikeyan

Gopinath Karthikeyan – Windows Site Reliability Engineer with about 12 years in enterprise Windows Server infrastructure, and founder of WinOps Academy. YouTube · LinkedIn

More in Interview prep