Unit 5 - Practice Quiz

CSC104 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 Which of the following best describes PowerShell?

A. A cross-platform task automation and configuration management framework
B. A web browser developed by Microsoft
C. A database management system
D. A strictly GUI-based administration tool

2 What is the standard file extension for a PowerShell script?

A. .vbs
B. .bat
C. .ps1
D. .cmd

3 What implies the naming convention used for PowerShell Cmdlets?

A. Subject-Object (e.g., Service-Get)
B. Adjective-Noun (e.g., New-File)
C. Verb-Noun (e.g., Get-Service)
D. Noun-Verb (e.g., File-Get)

4 Which character is used to denote a variable in PowerShell?

A. %
B. @
C. #
D. $

5 Which command is used to update the local help files in PowerShell?

A. Get-Help -Update
B. Update-Help
C. Install-Help
D. Upgrade-Help

6 In the PowerShell ISE, what does the 'ISE' stand for?

A. Internal System Executor
B. Interactive Shell Environment
C. Integrated Service Engine
D. Integrated Scripting Environment

7 How do you create a single-line comment in a PowerShell script?

A. ' This is a comment
B. # This is a comment
C. // This is a comment
D. <!-- This is a comment -->

8 Which syntax represents a multi-line comment block in PowerShell?

A. {{ Comment }}
B. <!-- Comment -->
C. / Comment /
D. <# Comment #>

9 Which cmdlet is used to request input from the user during script execution?

A. Get-Input
B. Input-User
C. Read-Host
D. Ask-Question

10 What is the primary function of the pipeline operator (|)?

A. It runs commands in the background.
B. It acts as a logical OR operator.
C. It passes the output object of one cmdlet as the input to the next cmdlet.
D. It redirects output to a file.

11 Which operator is used for equality comparison in PowerShell?

A. =
B. -eq
C. ==
D. -equals

12 If b = 5, what is the result of b?

A. 15
B. False
C. True
D. Error

13 Which wildcard character represents 'zero or more characters' in string matching?

A. %
B. #
C. ?
D. *

14 How do you define an array containing the numbers 1, 2, and 3?

A. $arr = list(1, 2, 3)
B. $arr = 1, 2, 3
C. $arr = [1, 2, 3]
D. $arr = {1, 2, 3}

15 How do you access the first element of an array named $myArray?

A. $myArray(0)
B. $myArray[1]
C. $myArray.First
D. $myArray[0]

16 What is the correct syntax for creating a hashtable?

A. @( Key = 'Value' )
B. { Key : 'Value' }
C. [ Key = 'Value' ]
D. @{ Key = 'Value' }

17 Which cmdlet is used to filter objects in a pipeline based on specific criteria?

A. Select-Object
B. Filter-Object
C. Sort-Object
D. Where-Object

18 Which cmdlet allows you to pick specific properties from an object and discard the rest?

A. Where-Object
B. Select-Object
C. Group-Object
D. Get-Member

19 What is the default Execution Policy on Windows client operating systems (like Windows 10/11)?

A. Unrestricted
B. Restricted
C. Bypass
D. RemoteSigned

20 Which command allows you to see all available aliases in the current session?

A. Get-Alias
B. Get-Command -Type Alias
C. List-Alias
D. Show-Alias

21 Which mathematical operator represents the modulus (remainder) in PowerShell?

A. \
B. Mod
C. /
D. %

22 Evaluate the following PowerShell expression: 10 -ne 10.

A. Null
B. True
C. False
D. 10

23 Which keyword is used to handle multiple specific conditions in a cleaner way than many elseif blocks?

A. case
B. choose
C. select
D. switch

24 What is the correct syntax for a basic if statement?

A. if b { ... }
B. if (b) then ...
C. if [b] then ...
D. if (b) { ... }

25 Which loop type is best used when you know the exact number of iterations in advance?

A. for
B. do-while
C. while
D. until

26 Which loop ensures that the code block is executed at least once?

A. for loop
B. foreach loop
C. while loop
D. do-while loop

27 What represents the 'current object' in a pipeline iteration (e.g., inside ForEach-Object)?

A. $current
B. $this
C. PSItem
D. $obj

28 To create a function named Get-Time, which keyword is used?

A. def Get-Time
B. cmdlet Get-Time
C. function Get-Time
D. func Get-Time

29 Inside a function, how do you define input variables?

A. Using args[] only
B. Inside a param() block
C. Inside the begin block
D. Using input()

30 What is the scope of a variable defined inside a function by default?

A. Global
B. Local (Function)
C. Script
D. Private

31 How can you modify a variable in the Global scope from inside a function?

A. Set-Global $variableName
B. $variableName = 'value' -Scope Global
C. export $variableName
D. $global:variableName = 'value'

32 Which construct is used for error handling in PowerShell?

A. try...catch...finally
B. on error resume next
C. check...handle
D. if...error...then

33 Which automatic variable contains the error object inside a catch block?

A. $ErrorMsg
B. $Exception
C. $Caught
D. $_

34 What is a PowerShell Profile?

A. A script that runs automatically when you start PowerShell
B. A configuration file for the Windows Registry
C. A summary of cmdlet usage stats
D. A user's login credentials

35 How do you run a script named deploy.ps1 located in the current directory?

A. deploy.ps1
B. ./deploy.ps1 or .\deploy.ps1
C. exec deploy.ps1
D. run deploy.ps1

36 Which cmdlet is used to format output as a table?

A. Format-List
B. Out-Table
C. Show-Table
D. 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?

A. Period .
B. Semicolon ;
C. Comma ,
D. Pipe |

38 Which operator performs a case-insensitive logical 'AND'?

A. -and
B. &
C. &&
D. AND

39 What is the result of "5" + 5 in PowerShell?

A. Null
B. "55"
C. 10
D. Error

40 How do you cast a variable $x explicitly to an integer?

A. $x as int
B. (int)$x
C. convert($x, int)
D. [int]$x

41 Which cmdlet is used to export data to a CSV file?

A. Export-Csv
B. ConvertTo-Csv
C. Write-Csv
D. Out-File

42 In the variable $env:Path, what does the env: drive represent?

A. The Envelope settings
B. Encryption keys
C. The Environment Variable provider
D. An external hard drive

43 Which loop is designed specifically to iterate over a collection of objects?

A. while
B. do-until
C. foreach
D. for

44 What is the purpose of $ErrorActionPreference?

A. To set the background color for error messages
B. To log errors to a text file automatically
C. To configure how PowerShell responds to non-terminating errors
D. To set the default help language

45 If you want to view the properties and methods of an object, which cmdlet should you pipe it to?

A. Inspect-Object
B. Show-Object
C. Get-Member
D. Get-Properties

46 Which logical operator returns True if either condition is true?

A. -not
B. -or
C. -and
D. -xor

47 Using LaTeX notation, if a variable represents and we want to calculate in PowerShell, which operator is used for the exponent?

A. [Math]::Pow()
B. exp
C. ^
D. **

48 What is the output of the following loop logic?
i++; Write-Output i -lt 3)

A. 1, 2, 3
B. 0, 1, 2, 3
C. 1, 2
D. 0, 1, 2

49 Which parameter in Get-ChildItem allows you to search through subdirectories?

A. -All
B. -Sub
C. -Recurse
D. -Deep

50 Which command stops the current script execution immediately?

A. exit
B. pause
C. stop
D. break