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