Unit 5: PowerShell Basics and Core Concepts - Practice Quiz
1 Which of the following best describes PowerShell?
2 What is the standard file extension for a PowerShell script?
3 What implies the naming convention used for PowerShell Cmdlets?
File-Get)
New-File)
Get-Service)
Service-Get)
4 Which character is used to denote a variable in PowerShell?
5 Which command is used to update the local help files in PowerShell?
Upgrade-Help
Update-Help
Install-Help
Get-Help -Update
6 In the PowerShell ISE, what does the 'ISE' stand for?
7 How do you create a single-line comment in a PowerShell script?
8 Which syntax represents a multi-line comment block in PowerShell?
9 Which cmdlet is used to request input from the user during script execution?
Ask-Question
Input-User
Get-Input
Read-Host
10
What is the primary function of the pipeline operator (|)?
11 Which operator is used for equality comparison in PowerShell?
12
If $a = 10 and $b = 5, what is the result of $a -gt $b?
13 Which wildcard character represents 'zero or more characters' in string matching?
14 How do you define an array containing the numbers 1, 2, and 3?
$arr = [1, 2, 3]
$arr = 1, 2, 3
$arr = list(1, 2, 3)
$arr = {1, 2, 3}
15
How do you access the first element of an array named $myArray?
$myArray[0]
$myArray.First
$myArray(0)
$myArray[1]
16 What is the correct syntax for creating a hashtable?
@{ Key = 'Value' }
@( Key = 'Value' )
[ Key = 'Value' ]
{ Key : 'Value' }
17 Which cmdlet is used to filter objects in a pipeline based on specific criteria?
Sort-Object
Where-Object
Select-Object
Filter-Object
18 Which cmdlet allows you to pick specific properties from an object and discard the rest?
Group-Object
Select-Object
Get-Member
Where-Object
19 What is the default Execution Policy on Windows client operating systems (like Windows 10/11)?
20 Which command allows you to see all available aliases in the current session?
Show-Alias
Get-Command -Type Alias
List-Alias
Get-Alias
21 Which mathematical operator represents the modulus (remainder) in PowerShell?
22
Evaluate the following PowerShell expression: 10 -ne 10.
23
Which keyword is used to handle multiple specific conditions in a cleaner way than many elseif blocks?
select
case
choose
switch
24
What is the correct syntax for a basic if statement?
if ($a > $b) then ...
if $a > $b { ... }
if [$a -gt $b] then ...
if ($a -gt $b) { ... }
25 Which loop type is best used when you know the exact number of iterations in advance?
for
while
do-while
until
26 Which loop ensures that the code block is executed at least once?
while loop
do-while loop
foreach loop
for loop
27
What represents the 'current object' in a pipeline iteration (e.g., inside ForEach-Object)?
$_ or $PSItem
$this
$obj
$current
28
To create a function named Get-Time, which keyword is used?
cmdlet Get-Time
def Get-Time
func Get-Time
function Get-Time
29 Inside a function, how do you define input variables?
param() block
begin block
input()
args[] only
30 What is the scope of a variable defined inside a function by default?
31 How can you modify a variable in the Global scope from inside a function?
$global:variableName = 'value'
$variableName = 'value' -Scope Global
Set-Global $variableName
export $variableName
32 Which construct is used for error handling in PowerShell?
try...catch...finally
check...handle
on error resume next
if...error...then
33
Which automatic variable contains the error object inside a catch block?
$ErrorMsg
$Exception
$Caught
$_
34 What is a PowerShell Profile?
35
How do you run a script named deploy.ps1 located in the current directory?
run deploy.ps1
./deploy.ps1 or .\deploy.ps1
exec deploy.ps1
deploy.ps1
36 Which cmdlet is used to format output as a table?
Out-Table
Format-Table
Format-List
Show-Table
37 What acts as the 'End of Line' or command terminator in PowerShell if you want to put two commands on one line?
;
.
|
,
38 Which operator performs a case-insensitive logical 'AND'?
&&
AND
-and
&
39
What is the result of "5" + 5 in PowerShell?
40
How do you cast a variable $x explicitly to an integer?
convert($x, int)
$x as int
(int)$x
[int]$x
41 Which cmdlet is used to export data to a CSV file?
Export-Csv
Write-Csv
ConvertTo-Csv
Out-File
42
In the variable $env:Path, what does the env: drive represent?
43 Which loop is designed specifically to iterate over a collection of objects?
foreach
while
for
do-until
44
What is the purpose of $ErrorActionPreference?
45 If you want to view the properties and methods of an object, which cmdlet should you pipe it to?
Get-Member
Get-Properties
Show-Object
Inspect-Object
46
Which logical operator returns True if either condition is true?
-and
-or
-xor
-not
47 Using LaTeX notation, if a variable represents and we want to calculate in PowerShell, which operator is used for the exponent?
**
^
exp
48
What is the output of the following loop logic?
$i=0; do {$i++; Write-Output $i} while ($i -lt 3)
49
Which parameter in Get-ChildItem allows you to search through subdirectories?
-All
-Recurse
-Sub
-Deep
50 Which command stops the current script execution immediately?
pause
break
exit
stop
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →