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?
Service-Get)
New-File)
Get-Service)
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?
Get-Help -Update
Update-Help
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?
Get-Input
Input-User
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 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 = list(1, 2, 3)
$arr = 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(0)
$myArray[1]
$myArray.First
$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
Filter-Object
Sort-Object
Where-Object
18 Which cmdlet allows you to pick specific properties from an object and discard the rest?
Where-Object
Select-Object
Group-Object
Get-Member
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-Alias
Get-Command -Type Alias
List-Alias
Show-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?
case
choose
select
switch
24
What is the correct syntax for a basic if statement?
if b { ... }
if (b) then ...
if [b] then ...
if (b) { ... }
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?
for loop
foreach loop
while loop
do-while loop
27
What represents the 'current object' in a pipeline iteration (e.g., inside ForEach-Object)?
$current
$this
PSItem
$obj
28
To create a function named Get-Time, which keyword is used?
def Get-Time
cmdlet Get-Time
function Get-Time
func Get-Time
29 Inside a function, how do you define input variables?
args[] only
param() block
begin block
input()
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
$variableName = 'value' -Scope Global
export $variableName
$global:variableName = 'value'
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?
$ErrorMsg
$Exception
$Caught
$_
34 What is a PowerShell Profile?
35
How do you run a script named deploy.ps1 located in the current directory?
deploy.ps1
./deploy.ps1 or .\deploy.ps1
exec deploy.ps1
run deploy.ps1
36 Which cmdlet is used to format output as a table?
Format-List
Out-Table
Show-Table
Format-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?
Export-Csv
ConvertTo-Csv
Write-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
foreach
for
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?
-not
-or
-and
-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++; Write-Output i -lt 3)
49
Which parameter in Get-ChildItem allows you to search through subdirectories?
-All
-Sub
-Recurse
-Deep
50 Which command stops the current script execution immediately?
exit
pause
stop
break