In this article
Basics
What is PowerShell, and how is it different from a plain command prompt?
PowerShell is a command shell and scripting language whose commands pass objects to each other, not plain text. A traditional prompt or a bash script usually passes strings, so you cut text apart to find a value. In PowerShell the next command receives an object and reads its properties by name, as the Microsoft Learn pipeline page shows when it pipes a process object from one command to another. The same language serves interactive use and saved scripts.
Why it is asked: a strong answer names objects as the key difference, not just "it is Microsoft's shell". Read the full explanation: Microsoft Learn, about_Pipelines.
What is a cmdlet?
A cmdlet is a compiled PowerShell command, written as a class for .NET (Microsoft's software platform) and shipped with PowerShell or in a module, that by convention is named with an approved verb and a noun, such as Get-Process. Get-Verb lists the approved verbs. Cmdlets are written in .NET languages such as C#; see the .NET interview questions. The pattern makes names guessable: Get- reads something, Set- changes it and Remove- deletes it. Cmdlets return objects, not formatted text, and the shell formats those objects only when they reach the screen. Functions you write in PowerShell are not cmdlets, but they can follow the same naming habit.
Why it is asked: it checks that you know the vocabulary of the shell. Check it yourself: run Get-Help about_Core_Commands.
How do you find a command and learn how to use it?
Three commands cover discovery. Get-Command searches for commands by name, for example Get-Command *process*. Get-Help shows a command's syntax and parameters, and its -Examples switch prints sample usage. Get-Member lists what an object contains: the Microsoft Learn pipeline page says to pipe an object to it to list the object's properties. Use these before searching the web.
Why it is asked: self-sufficiency with the help system matters more than memorised cmdlet names. Read the full explanation: Microsoft Learn, about_Pipelines, accessed October 2026.
The pipeline
What is the PowerShell pipeline?
A pipeline is a series of commands connected by the pipeline operator |. Microsoft Learn describes it this way: "Each pipeline operator sends the results of the preceding command to the next command." Commands are processed in order from left to right, and the whole thing is handled as a single operation, with output displayed as it is generated (Microsoft Learn, about_Pipelines, accessed October 2026). So results usually stream through instead of waiting for each command to finish; the exceptions are commands such as Sort-Object and Group-Object, which must collect all their input before they emit anything.
Why it is asked: nearly every other PowerShell answer builds on it. Read the full explanation: Microsoft Learn, about_Pipelines.
What does "objects, not text" mean in the pipeline?
Each item that flows through the pipeline is an object with properties and methods, not a line of characters. The Microsoft Learn example is Get-Process notepad | Stop-Process: the first command emits an object representing the Notepad process, and the pipeline sends that object to Stop-Process, which needs no name or id parameter because the process arrives through the pipeline (Microsoft Learn, about_Pipelines, accessed October 2026). No text parsing is involved.
Why it is asked: it separates people who script in PowerShell from people who write bash habits in it. Read the full explanation: Microsoft Learn, about_Pipelines.
How does a command know which parameter receives the piped object?
This is parameter binding. The Microsoft Learn pipeline page has a section on it and says some parameters accept objects by value or by property name. By value means the whole piped object matches the type a parameter expects. By property name means a property of the object has the same name as a parameter, and PowerShell copies it across. Run Get-Help <command> -Full and look for "Accept pipeline input" on each parameter.
Why it is asked: it tests whether you can explain why a pipeline works, not only type one. Read the full explanation: Microsoft Learn, about_Pipelines, accessed October 2026.
What is the difference between Where-Object, Select-Object and ForEach-Object?
Get-Service | Where-Object Status -eq Running | Select-Object NameWhere-Object keeps only the objects that pass a test, Select-Object chooses which properties to keep, and ForEach-Object runs a script block once per object. For example, Get-Service | ForEach-Object { $_.Name.ToUpper() } upper-cases each service name; inside the script block, $_ is the current pipeline object. When a cmdlet has its own filter parameter, such as -Name, use it: filtering at the source, to the left of the pipe, handles fewer objects than collecting everything and filtering afterward.
Why it is asked: it checks whether you can shape output and think about efficiency. Check it yourself: run Get-Help Where-Object -Examples.
What are $_ and $PSItem?
$_ and $PSItem are the same automatic variable, which holds the current object in the pipeline. In a Where-Object or ForEach-Object script block it is the item being processed, as in Get-Service | ForEach-Object { $_.Name }, and in a catch block it holds the error record. It has no useful value outside such blocks. Microsoft Learn documents it in about_Automatic_Variables.
Why it is asked: it appears in almost every real pipeline, and candidates often use it without knowing what it is. Read the full explanation: Microsoft Learn, about_Automatic_Variables.
Knowing it is half the job. Saying it is the other half.
Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.
Start Free Trial →Variables, operators and quoting
What is the difference between = and -eq?
The = operator assigns a value to a variable, and -eq compares two values and returns true or false. Other comparison operators follow the same dash style: -ne, -gt, -lt, -like for wildcards and -match for regular expressions. String comparisons ignore case by default; -ceq is the case-sensitive form. Writing = inside an if condition by mistake assigns instead of testing.
Why it is asked: PowerShell does not use ==, and the habit slips for people from other languages. Read the full explanation: Microsoft Learn, about_Comparison_Operators, or check it yourself with Get-Help about_Comparison_Operators.
Why do you write $null on the left of a comparison?
When the left side of -eq is an array, the operator filters the array and returns the matching items instead of a single true or false. So $value -eq $null can return an empty result for an array that contains no nulls, and an empty result counts as false. If the array does contain nulls, the comparison returns those nulls, which also read as false. Writing $null -eq $value always compares one value against the whole thing and returns a clear true or false.
Why it is asked: it is a small trap that shows whether you have been bitten by it. Check it yourself: run Get-Help about_Comparison_Operators.
What is the difference between single and double quotes?
Single quotes make a literal string: what you type is what you get. Double quotes expand variables and expressions inside the string, so "Hello, $name" inserts the value of $name, and "Total: $($items.Count)" evaluates a property inside $( ). Use single quotes by default and double quotes only when you want expansion, which also keeps paths and patterns free of accidental substitution.
Why it is asked: it is quick to check and common in real scripts. Check it yourself: run Get-Help about_Quoting_Rules.
What are arrays and hashtables used for?
An array is an ordered list of values, written @('a', 'b') and read by position. A hashtable is a set of key and value pairs, written @{ Name = 'web'; Role = 'api' } and read by key, as in $server.Name. Use an array for a list of similar items and a hashtable for a record with named fields, or to pass named parameters to a command with splatting, which means passing a hashtable as @params so its keys become parameter names.
Why it is asked: these two types carry most data handling in scripts. Check it yourself: run Get-Help about_Arrays and Get-Help about_Hash_Tables.
Functions and scripts
What is an advanced function?
An advanced function is a function that declares [CmdletBinding()] or a [Parameter()] attribute on a parameter, so it behaves like a cmdlet, with the common parameters such as -Verbose and -ErrorAction added automatically. A plain function takes whatever you pass; an advanced function declares typed, validated parameters:
function Get-Greeting {
[CmdletBinding()]
param([Parameter(Mandatory)][string]$Name)
"Hello, $Name"
}The Mandatory attribute makes PowerShell prompt for a missing value in an interactive session instead of running with an empty one; in a non-interactive run the command fails instead.
Why it is asked: it shows whether you write reusable tools or only one-off scripts. Read the full explanation: Microsoft Learn, about_Functions_Advanced.
What is the difference between Write-Host and Write-Output?
Write-Output sends objects to the success output stream, so the next command in a pipeline, or a variable assignment, can receive them. Write-Host writes text to the host, normally the screen, and nothing downstream receives it by default (in current versions it goes to the information stream, which you can capture with 6>&1). Emit data with Write-Output (or simply by returning the value) and keep Write-Host for messages meant for the person at the console.
Why it is asked: it shows whether you understand that a function's output is data, not display. Check it yourself: run Get-Help Write-Output.
How do modules work in PowerShell?
A module is a package of commands, such as cmdlets and functions, that you load into a session. Get-Module -ListAvailable lists the modules installed in the folders named in $env:PSModulePath, and Import-Module loads one. PowerShell usually autoloads a module the first time you run one of its commands. Modules such as ActiveDirectory or Az add their own cmdlets (Microsoft Learn, about_Modules).
Why it is asked: real jobs depend on modules, and "command not found" is often a module problem. Read the full explanation: Microsoft Learn, about_Modules.
Errors
How does try, catch and finally work in PowerShell?
A try block holds the code to monitor, a catch block handles a terminating error from it, and a finally block runs afterward whether or not an error happened. Microsoft Learn says an error in try is first saved in the $Error variable, then PowerShell looks for a matching catch; inside it, $_ or $PSItem holds the error record. A catch can name error types, and the finally block is for freeing resources (Microsoft Learn, about_Try_Catch_Finally, April 2026).
Why it is asked: error handling separates scripts that work once from scripts that run unattended. Read the full explanation: Microsoft Learn, about_Try_Catch_Finally.
Why does my catch block not run when a command fails?
The catch block handles terminating errors, and many cmdlet failures are non-terminating: PowerShell writes the error and carries on with the next item. The usual fix is adding -ErrorAction Stop to the command, which turns its error into a terminating one that catch can see. The $ErrorActionPreference variable sets the default for a whole scope. Microsoft Learn also notes it can suppress throw when set to SilentlyContinue or Ignore (Microsoft Learn, about_Try_Catch_Finally, April 2026).
Why it is asked: it is the most common error-handling bug. Check it yourself: run Get-Help about_Error_Handling.
Running scripts and remote machines
What is an execution policy, and is it a security feature?
An execution policy is a setting that controls which PowerShell scripts the shell will run, with values such as Restricted, AllSigned, RemoteSigned, Unrestricted and Bypass. A good answer calls it a safeguard against running a script by accident, not a security boundary, because, as Microsoft Learn puts it, the policy "isn't a security system" and users "can easily bypass a policy by typing the script contents at the command line". Real protection comes from permissions, code signing and application controls.
Why it is asked: it tests whether you separate convenience controls from security controls. Read the full explanation: Microsoft Learn, about_Execution_Policies.
How do you run commands on another computer?
PowerShell remoting runs commands on a remote machine and returns the results to you. Invoke-Command -ComputerName server01 -ScriptBlock { Get-Service } runs a script block there, and it can target many computers in one call. Enter-PSSession opens an interactive session on one machine. Objects come back as copies, so they keep their properties but usually lose their methods; do work that needs methods on the remote side. Remoting needs setup first: Windows PowerShell remoting runs over Windows Remote Management (WinRM), while PowerShell 7 can also remote over Secure Shell (SSH) (WinRM: Microsoft Learn, about_Remote_Requirements).
Why it is asked: administration at scale depends on it. Read the full explanation: Microsoft Learn, about_Remote_Requirements.
What is the difference between Windows PowerShell and the newer PowerShell?
Windows PowerShell 5.1, the last Windows-only edition, ships with Windows. PowerShell 7.x is built on modern .NET (Microsoft's cross-platform runtime) and is cross-platform: Microsoft Learn's What is PowerShell? says it runs on Windows, Linux and macOS (as of October 2026). Both can be installed side by side, and a module written only for the older edition can fail in the newer one, so check compatibility when moving scripts.
Why it is asked: it shows whether you know which shell a job actually uses. Check it yourself: run $PSVersionTable in each shell.
Follow-up questions
What are the common PowerShell interview questions?
The twenty above cover the recurring ones: cmdlets, the object pipeline, filtering, comparison operators, quoting, functions, modules, output, error handling, execution policy and remoting. For the wider coding-round routine, see the coding interview guide, and for another scripting language's question set, the JavaScript interview questions.
What PowerShell interview questions are asked for experienced administrators?
Expect the same topics with more depth and a scenario: write a pipeline that reports on many machines, explain why a catch did not fire (the entry on non-terminating errors above is the usual answer), or design a script that runs unattended and logs failures. Be ready to explain a trade-off, not only a definition. Related ground is in the Linux system administration questions and the networking interview questions.
Is PowerShell only for Windows?
No. Windows PowerShell 5.1 is Windows-only, but PowerShell 7.x runs on Windows, Linux and macOS, as Microsoft Learn's What is PowerShell? says (as of October 2026). Say which edition you mean in an answer.
How do you practise for a PowerShell interview?
Open a session and run each answer above yourself, using Get-Member to inspect the objects and Get-Help to check parameters. Then say each answer aloud in your own words. PowerShell often appears next to other languages, such as C#, and in broader roles like full stack development.
- PowerShell pipes objects, not text, so you read properties by name instead of parsing strings.
- Learn the discovery trio:
Get-Command,Get-HelpandGet-Member. - Use
-eqto compare,=to assign, and put$nullon the left. catchhandles terminating errors; add-ErrorAction Stopto catch a cmdlet's non-terminating one.- An execution policy is a safeguard, not a security boundary.
Sources
- about_Pipelines (Microsoft Learn, PowerShell 7.6 documentation) — Microsoft Learn, 26 Oct 2026
- about_Try_Catch_Finally (Microsoft Learn, PowerShell 7.6 documentation) — Microsoft Learn, 2 Apr 2026
- about_Comparison_Operators (Microsoft Learn, PowerShell documentation) — Microsoft Learn, 26 Oct 2026
- What is PowerShell? (Microsoft Learn) — Microsoft Learn, 12 Aug 2026
- about_Execution_Policies (Microsoft Learn) — Microsoft Learn, 26 Oct 2026
- about_Automatic_Variables (Microsoft Learn) — Microsoft Learn, 26 Oct 2026
- about_Modules (Microsoft Learn) — Microsoft Learn, 26 Oct 2026
- about_Remote_Requirements (Microsoft Learn) — Microsoft Learn, 26 Oct 2026
- about_Functions_Advanced (Microsoft Learn) — Microsoft Learn, 26 Oct 2026