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. .bat
B. .ps1
C. .cmd
D. .vbs

3 What implies the naming convention used for PowerShell Cmdlets?

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

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. Upgrade-Help
B. Get-Help -Update
C. Install-Help
D. Update-Help

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

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

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. Ask-Question
B. Input-User
C. Read-Host
D. Get-Input

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 redirects output to a file.
D. It passes the output object of one cmdlet as the input to the next cmdlet.

11 Which operator is used for equality comparison in PowerShell?

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

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

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

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 = {1, 2, 3}
B. $arr = 1, 2, 3
C. $arr = list(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.First
C. $myArray[0]
D. $myArray[1]

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. Sort-Object
B. Where-Object
C. Select-Object
D. Filter-Object

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

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

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. List-Alias
B. Get-Alias
C. Show-Alias
D. Get-Command -Type Alias

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

32 Which construct is used for error handling in PowerShell?

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

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

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

34 What is a PowerShell Profile?

A. A configuration file for the Windows Registry
B. A summary of cmdlet usage stats
C. A script that runs automatically when you start PowerShell
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. exec deploy.ps1
C. run deploy.ps1
D. ./deploy.ps1 or .\deploy.ps1

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

A. Out-Table
B. Format-Table
C. Show-Table
D. Format-List

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. Pipe |
C. Comma ,
D. Semicolon ;

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

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

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

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

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

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

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

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

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

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

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

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

44 What is the purpose of $ErrorActionPreference?

A. To log errors to a text file automatically
B. To set the background color for error messages
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. Show-Object
B. Inspect-Object
C. Get-Member
D. Get-Properties

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

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

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. ^
C. exp
D. **

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

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

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

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

50 Which command stops the current script execution immediately?

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