Core Concepts Interviewers Probe First
Nearly every PowerShell interview opens with some variant of 'explain the pipeline,' because the answer reveals whether a candidate understands PowerShell as an object-oriented shell rather than treating it like a text-based one with different syntax. A strong answer distinguishes the pipeline (objects flowing between cmdlets), the difference between Format-* cmdlets (which produce display-only text and should always be last) and Select-Object (which produces objects you can still pipe further), and explains why piping the output of Format-Table into another cmdlet is almost always a mistake.
Cricket analogy: It is like an interviewer asking a young batsman to explain their technique against spin — the answer reveals whether they actually understand footwork and reading the ball, or just memorized commentary phrases.
# Correct: filter/select first (still objects), format last (display only)
Get-Process | Where-Object CPU -gt 50 | Select-Object Name, CPU | Sort-Object CPU -Descending
# Wrong: Format-Table produces display strings, nothing meaningful downstream
Get-Process | Format-Table Name, CPU | Export-Csv procs.csv # produces garbage outputScoping and Variable Lifetime
A frequent trick question asks why a variable set inside a function or a ForEach-Object -Parallel block doesn't appear to the caller afterward — the answer is PowerShell's scoping rules: each function, script block, and module gets its own scope by default, and child scopes can read parent variables but writes stay local unless you explicitly use $script: or $global: or return the value. Candidates who understand dot-sourcing (. .\script.ps1) versus normal invocation (.\script.ps1) usually also understand this well, since dot-sourcing runs the script in the current scope instead of creating a new child scope.
Cricket analogy: It is like a substitute fielder who can see the whole match from the boundary but has no authority to change the batting order — they can observe the outer scope but can't write back to it unless explicitly given that role.
Remoting and Sessions
Expect a question comparing Invoke-Command against a remote computer name (which opens a new session, runs the command, and tears it down) with Invoke-Command against a persistent session created by New-PSSession (which keeps variables and imported modules alive across multiple calls, useful for a multi-step remote workflow). Also expect WinRM basics: PowerShell remoting listens on TCP 5985 (HTTP) or 5986 (HTTPS) by default, requires Enable-PSRemoting on the target, and by default trusts only domain-joined or explicitly TrustedHosts-listed machines when not using HTTPS or Kerberos.
Cricket analogy: It is like the difference between a single quick net session with a coach who leaves after one drill versus hiring that coach for a full week where progress and adjustments carry over from session to session.
Practical Scenario Questions
Interviewers often present a scenario like 'this script works when I run it manually but fails as a Scheduled Task' to see if a candidate knows the real-world culprits: a different working directory (use $PSScriptRoot instead of relative paths), a service account lacking rights the interactive user had, or a missing module because the module was only installed for CurrentUser scope rather than AllUsers. A candidate who immediately reaches for those three explanations, rather than guessing randomly, signals real production experience rather than textbook-only knowledge.
Cricket analogy: It is like a bowler who nails yorkers in the nets but loses the length under match pressure — an experienced coach immediately checks run-up rhythm, crowd noise, and fatigue rather than guessing blindly at the cause.
When practicing for interviews, be ready to explain $PSScriptRoot, the difference between dot-sourcing and normal script invocation, and why a script that runs fine interactively can fail under a Scheduled Task's different working directory and account context — these three come up constantly in real-world debugging questions.
Avoid answering pipeline questions with Bash-flavored assumptions (like assuming everything is text). Interviewers specifically probe for this misconception because it is the most common gap between candidates who have only used Bash and those who genuinely understand PowerShell's object model.
- Be ready to explain the object pipeline clearly, and why Format-* cmdlets should always come last.
- Understand PowerShell scoping: child scopes read parent variables but writes stay local unless using $script:/$global: or return.
- Know the difference between dot-sourcing (. .\script.ps1) and normal invocation for scope behavior.
- Be able to explain Invoke-Command against a computer name versus a persistent New-PSSession.
- Know WinRM basics: ports 5985/5986, Enable-PSRemoting, and TrustedHosts for non-domain scenarios.
- Practice the classic 'works interactively, fails as a Scheduled Task' debugging scenario ($PSScriptRoot, service account rights, module scope).
- Avoid answering from a Bash mental model — emphasize PowerShell's object-oriented pipeline explicitly.
Practice what you learned
1. Why should Format-Table or Format-List always be the last cmdlet in a pipeline?
2. What happens to a variable set inside a PowerShell function by default?
3. What is the key difference between dot-sourcing a script and running it normally?
4. What advantage does New-PSSession offer over a one-off Invoke-Command against a computer name?
5. A script runs correctly when executed manually but fails under a Scheduled Task. What is a likely cause an experienced PowerShell engineer would check first?
Was this page helpful?
You May Also Like
PowerShell Best Practices
Practical conventions for writing PowerShell scripts and functions that stay readable, safe, and maintainable as they grow.
PowerShell vs Bash
How PowerShell's object pipeline compares to Bash's text pipeline, and when to reach for each shell.
PowerShell Quick Reference
A condensed reference of the PowerShell syntax, operators, and cmdlets you reach for most often day to day.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics