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)
Get-Service)
New-File)
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?
Update-Help
Get-Help -Update
Install-Help
Upgrade-Help
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?
Input-User
Get-Input
Read-Host
Ask-Question
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 = {1, 2, 3}
$arr = list(1, 2, 3)
15
How do you access the first element of an array named $myArray?
$myArray(0)
$myArray[1]
$myArray[0]
$myArray.First
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?
Where-Object
Filter-Object
Select-Object
Sort-Object
18 Which cmdlet allows you to pick specific properties from an object and discard the rest?
Where-Object
Get-Member
Group-Object
Select-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?
List-Alias
Get-Alias
Show-Alias
Get-Command -Type 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?
choose
case
select
switch
24
What is the correct syntax for a basic if statement?
if $a > $b { ... }
if ($a -gt $b) { ... }
if [$a -gt $b] then ...
if ($a > $b) then ...
25 Which loop type is best used when you know the exact number of iterations in advance?
for
do-while
while
until
26 Which loop ensures that the code block is executed at least once?
foreach loop
for loop
while loop
do-while loop
27
What represents the 'current object' in a pipeline iteration (e.g., inside ForEach-Object)?
$obj
$_ or $PSItem
$this
$current
28
To create a function named Get-Time, which keyword is used?
cmdlet Get-Time
func Get-Time
function Get-Time
def Get-Time
29 Inside a function, how do you define input variables?
begin block
input()
args[] only
param() block
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?
$variableName = 'value' -Scope Global
$global:variableName = 'value'
Set-Global $variableName
export $variableName
32 Which construct is used for error handling in PowerShell?
try...catch...finally
on error resume next
check...handle
if...error...then
33
Which automatic variable contains the error object inside a catch block?
$Caught
$_
$ErrorMsg
$Exception
34 What is a PowerShell Profile?
35
How do you run a script named deploy.ps1 located in the current directory?
./deploy.ps1 or .\deploy.ps1
run deploy.ps1
deploy.ps1
exec 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?
$x as int
[int]$x
convert($x, int)
(int)$x
41 Which cmdlet is used to export data to a CSV file?
Write-Csv
Export-Csv
Out-File
ConvertTo-Csv
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?
for
while
do-until
foreach
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?
Show-Object
Get-Properties
Get-Member
Inspect-Object
46
Which logical operator returns True if either condition is true?
-and
-or
-not
-xor
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?
-Recurse
-Sub
-All
-Deep
50 Which command stops the current script execution immediately?
exit
pause
stop
break
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 →