Unit 5 - Practice Quiz
CSC104
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?
Upgrade-Help
Get-Help -Update
Update-Help
Install-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
Read-Host
Input-User
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 = {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[1]
$myArray(0)
$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?
Select-Object
Where-Object
Filter-Object
Sort-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-Alias
Show-Alias
List-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?
switch
case
select
choose
24
What is the correct syntax for a basic if statement?
if b { ... }
if (b) { ... }
if [b] then ...
if (b) then ...
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?
while loop
for loop
do-while loop
foreach loop
27
What represents the 'current object' in a pipeline iteration (e.g., inside ForEach-Object)?
$this
PSItem
$obj
$current
28
To create a function named Get-Time, which keyword is used?
def Get-Time
func Get-Time
function Get-Time
cmdlet Get-Time
29 Inside a function, how do you define input variables?
param() block
input()
args[] only
begin 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?
$global:variableName = 'value'
export $variableName
$variableName = 'value' -Scope Global
Set-Global $variableName
32 Which construct is used for error handling in PowerShell?
try...catch...finally
if...error...then
on error resume next
check...handle
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
./deploy.ps1 or .\deploy.ps1
exec deploy.ps1
36 Which cmdlet is used to format output as a table?
Format-List
Format-Table
Out-Table
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?
(int)$x
[int]$x
$x as int
convert($x, int)
41 Which cmdlet is used to export data to a CSV file?
Out-File
Export-Csv
Write-Csv
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
foreach
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
Show-Object
Get-Properties
Inspect-Object
46
Which logical operator returns True if either condition is true?
-and
-xor
-or
-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++; Write-Output i -lt 3)
49
Which parameter in Get-ChildItem allows you to search through subdirectories?
-Deep
-Recurse
-All
-Sub
50 Which command stops the current script execution immediately?
break
pause
exit
stop