Unlock hundreds more features
Save your Quiz to the Dashboard
View and Export Results
Use AI to Create Quizzes and Analyse Results

Sign inSign in with Facebook
Sign inSign in with Google

PowerShell Fundamentals Knowledge Test Challenge

Test Your Basic PowerShell Scripting Skills

Difficulty: Moderate
Questions: 20
Learning OutcomesStudy Material
Colorful paper art illustrating a quiz on PowerShell Fundamentals Knowledge Test

Ready to challenge yourself with a PowerShell quiz that sharpens your scripting skills? This PowerShell Fundamentals Knowledge Test is perfect for IT pros, DevOps enthusiasts, and anyone eager to master shell automation. With customizable questions and instant feedback, you can explore essential cmdlets and pipeline techniques while comparing your performance to related topics like IT Fundamentals Knowledge Test or the C# Fundamentals Quiz . Every question is editable - tailor it in our editor to suit your learning journey at no cost. Dive into more quizzes to expand your skills across domains.

Which cmdlet displays the help content for PowerShell commands?
Show-Help
Get-Help
Help-Show
Display-Help
The Get-Help cmdlet retrieves help information for PowerShell commands. It is designed specifically to show usage, parameters, and examples for cmdlets.
How do you assign the string value "Alice" to a variable named $name?
name = "Alice"
set name "Alice"
$name := "Alice"
$name = "Alice"
PowerShell uses the equals sign (=) to assign values, and variable names must be prefixed with a dollar sign. The correct syntax is `$name = "Alice"`.
What symbol is used to pipe the output of one cmdlet to another in PowerShell?
&
|
||
;
The vertical bar (|) is the pipeline operator in PowerShell. It passes the output of one cmdlet as input to the next cmdlet in the command chain.
Which cmdlet lists the files and directories in the current location?
Get-Items
List-Items
Get-ChildItem
Show-Directory
Get-ChildItem retrieves the items (files and directories) in a specified location. It is commonly aliased as `ls` or `dir` in PowerShell.
In PowerShell, how do you reference the value stored in a variable?
$variable
variable
&variable
%variable
Variables in PowerShell must be prefixed with a dollar sign ($) to reference their values. This distinguishes them from literal text or cmdlet names.
Which cmdlet filters objects in the pipeline based on specified criteria?
Filter-Object
Where-Object
Sort-Object
Select-String
Where-Object evaluates a script block against each object in the pipeline and passes only those that match the criteria. It is the standard filter cmdlet in PowerShell.
How would you sort services by their status in descending order?
Get-Service | Order-By Status Desc
Get-Service | Sort-Object Status -Descending
Get-Service | Sort-Object -Property Status -Ascending
Get-Service | Sort Status /Descending
The Sort-Object cmdlet sorts objects by property, and the -Descending switch reverses the sort order. `Get-Service | Sort-Object Status -Descending` is the correct syntax.
Which statement will iterate over each item in the $items array?
while ($item in $items) { … }
for ($item in $items) { … }
foreach ($item in $items) { … }
do { … } until ($item in $items)
The `foreach` statement in PowerShell iterates over each element in a collection. It uses the `in` keyword to process each item sequentially.
To suppress non-terminating errors in a cmdlet, which common parameter should you use?
-ErrorAction SilentlyContinue
-IgnoreError
-ErrorControl Continue
-OnError Ignore
The `-ErrorAction SilentlyContinue` parameter tells PowerShell to ignore non-terminating errors without displaying them. It is a common way to handle less critical errors quietly.
Which cmdlet imports a PowerShell module into the current session?
Import-Module
Install-Module
Add-Module
Load-Module
Import-Module adds the cmdlets and functions from a module into the current session. Install-Module downloads modules, but Import-Module loads them for use.
What command sets the execution policy to allow running locally created scripts without requiring signing?
Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy AllSigned
Set-ExecutionPolicy Bypass
Set-ExecutionPolicy RemoteSigned
RemoteSigned allows local scripts to run without a digital signature but requires remote scripts to be signed. It provides a balance between security and flexibility.
Given $user = "Bob", which command correctly outputs "Hello Bob"?
Write-Output "Hello $user"
Write-Output "Hello `$user"
Write-Output 'Hello $user'
Write-Output Hello $user
Double-quoted strings in PowerShell support variable interpolation, so `$user` is replaced with its value. Single quotes treat it as literal text.
Which construct is used to handle terminating errors in a script block?
begin { } end { }
trap { }
if { } else { }
try { } catch { }
The try/catch construct explicitly handles terminating errors by catching exceptions thrown in the try block. While `trap` can handle errors, try/catch is more structured for error handling.
To display the Name and Status properties of services in a table format, which pipeline is correct?
Get-Service | Select-Object Name, Status | Format-Table
Get-Service | Sort-Object Name, Status
Get-Service | Where-Object Name, Status
Get-Service | Format-List Name, Status
Select-Object picks the specified properties and Format-Table arranges them in a table. This combination is used for clear tabular display of selected fields.
How do you view the members and methods of objects returned by Get-Process?
Get-Process | Get-Member
Show-Member Get-Process
Get-Process | Format-List Members
Get-Member(Get-Process)
Get-Member inspects objects in the pipeline and lists their properties and methods. Piping Get-Process output into Get-Member reveals the object structure.
Which block should you place at the top of a script to define parameters named Name and Age?
function($Name, $Age)
param([string]$Name, [int]$Age)
parameters([string]Name, [int]Age)
set-parameters Name, Age
The `param` block declares script parameters and their types. It must appear before any executable code in the script for proper parameter binding.
Which cmdlet creates a new PowerShell module manifest file?
New-Module
New-Manifest
New-PsModule
New-ModuleManifest
New-ModuleManifest generates a module manifest (.psd1) file with metadata about the module. It is the standard tool for creating manifests.
To set a breakpoint on line 15 of script.ps1 for debugging, which command is correct?
Set-PSBreakpoint -Script script.ps1 -Line 15
Debug-Script -Line 15
Breakpoint-Set -Script script.ps1 -Line 15
Add-Breakpoint script.ps1 15
Set-PSBreakpoint is the built-in cmdlet to create breakpoints. You specify the script and line number to pause execution at that point.
To enforce that all scripts, including local ones, must be signed before execution, which policy should you set?
RemoteSigned
Bypass
AllSigned
Unrestricted
AllSigned requires that every script and configuration file be signed by a trusted publisher. This policy enforces the highest level of script signing.
In an advanced function, which attribute on a parameter allows input directly from the pipeline by property name?
[Param()]
[Parameter(ValueFromPipelineByPropertyName=$true)]
[CmdletBinding()]
ValueFromPipeline=$true
The `ValueFromPipelineByPropertyName` parameter attribute lets PowerShell bind incoming objects from the pipeline by matching property names. It is used inside the Parameter() decorator.
0
{"name":"Which cmdlet displays the help content for PowerShell commands?", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Which cmdlet displays the help content for PowerShell commands?, How do you assign the string value \"Alice\" to a variable named $name?, What symbol is used to pipe the output of one cmdlet to another in PowerShell?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}

Learning Outcomes

  1. Analyse basic PowerShell cmdlets and their uses
  2. Apply variables and data types in scripts
  3. Demonstrate pipeline operations for data processing
  4. Identify proper use of loops and conditional statements
  5. Evaluate error handling and debugging techniques
  6. Master module management and script execution policies

Cheat Sheet

  1. Master Essential PowerShell Cmdlets - Get-Help shows usage examples and syntax for any cmdlet, while Get-Command lets you explore available commands by verb or noun. Get-Member reveals object properties and methods so you can manipulate data confidently. Together, these cmdlets form the foundation of effective PowerShell scripting. PowerShell on Wikipedia
  2. Understand Variables and Data Types - Use the $ symbol to declare variables and assign values like strings, integers, and arrays to store information. Understanding PowerShell's dynamic typing and explicit type casting prevents common data mishaps. Mastering variables is crucial for building flexible, reusable scripts. PowerShell on Wikipedia
  3. Utilize the Pipeline for Data Processing - The pipeline (|) passes output of one cmdlet directly as input to another, letting you chain commands without creating temporary files. You can filter, sort, and format data on the fly using cmdlets like Where-Object, Sort-Object, and Format-Table. This streamlined approach is at the heart of PowerShell's data processing magic. PowerShell on Wikipedia
  4. Implement Conditional Statements - Use if, elseif, and else blocks to control which sections of your script run based on specific criteria. Conditional logic allows your automation to make decisions - like checking if a service is running or if a file exists - before proceeding. Mastering conditionals means your scripts can react intelligently to different scenarios. Control Flow with Conditional Statements
  5. Employ Looping Constructs - Loops such as for, foreach, and while let you perform repetitive tasks without duplicating code. Whether processing every file in a directory or iterating through a list of users, loops automate bulk operations efficiently. Learning which loop fits each scenario speeds up your scripts and keeps them neat. Looping Techniques in PowerShell
  6. Handle Errors Gracefully - Encapsulate risky code in try, catch, and finally blocks to capture and respond to exceptions, preventing script failures. You can log errors, retry operations, or clean up resources in a structured way, ensuring reliable automation. Good error handling also makes troubleshooting easier when things go wrong. Error Handling in PowerShell
  7. Manage Modules Effectively - Import modules with Import-Module to add new cmdlets and features from the PowerShell Gallery or custom scripts. Keeping modules up to date and removing unused ones streamlines your environment and avoids version conflicts. Understanding module scope and autoloading helps you manage dependencies cleanly. PowerShell Modules on Wikipedia
  8. Understand Script Execution Policies - Execution policies like Restricted, RemoteSigned, and Unrestricted govern which scripts can run on your system. By using Get-ExecutionPolicy and Set-ExecutionPolicy, you balance security and flexibility. This knowledge protects your systems from untrusted code while allowing authorized automation. Execution Policies on Wikipedia
  9. Explore Object-Oriented Features - PowerShell treats output as objects, letting you access properties and methods directly rather than parsing text. You can create custom objects, define classes, and overload methods to build advanced modules. Embracing these capabilities transforms scripts into modular, self-describing code. PowerShell Object Model
  10. Practice Debugging Techniques - Use Set-PSBreakpoint and Get-PSCallStack to set breakpoints and inspect call stacks, pinpointing errors in real time. Supplement with Write-Debug and Write-Verbose to output diagnostic messages without cluttering normal script output. Regular debugging drills sharpen your ability to find and fix issues swiftly. Debugging PowerShell Scripts
Powered by: Quiz Maker