Unit 6 - Practice Quiz

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

1 Which PowerShell cmdlet is primarily used to load a module into the current session?

A. Load-Module
B. Import-Module
C. Get-Module
D. Install-Module

2 Which environment variable stores the paths where PowerShell looks for modules?

A. $env:PSHome
B. $env:ModulePath
C. $env:PSModulePath
D. $env:Path

3 What is the file extension for a PowerShell Module Manifest file?

A. .xml
B. .ps1
C. .psd1
D. .psm1

4 Which cmdlet is used to import data from a Comma-Separated Value file and create objects from it?

A. Read-Csv
B. ConvertFrom-Csv
C. Import-Csv
D. Get-Content

5 When converting a PowerShell object to JSON format, which cmdlet is used?

A. Out-Json
B. Format-Json
C. ConvertTo-Json
D. Export-Json

6 Which cmdlet allows you to read an XML file and navigate its nodes as properties?

A. [xml](Get-Content path)
B. Import-Xml
C. Get-Content -AsXml
D. Select-Xml

7 Which cmdlet is most appropriate for prompting a user to input a password securely?

A. Read-Input -Secure
B. Get-Credential
C. Read-Host -AsSecureString
D. Read-Host -MaskInput

8 Which cmdlet creates a graphical window allowing users to select one or more items from a list?

A. Select-Object -UI
B. Read-Choice
C. Show-Menu
D. Out-GridView -PassThru

9 In a text-based menu script, which statement is most efficient for handling multiple specific user choices?

A. switch
B. foreach
C. if...else
D. while

10 Which cmdlet is used to stop a running Windows service?

A. Stop-Service
B. Disable-Service
C. End-Service
D. Kill-Service

11 To retrieve a list of all processes currently consuming more than 100MB of memory, which command structure is correct?

A. Get-Process | Filter-Object { $_.Memory -gt 100MB }
B. Get-Process | Where-Object { $_.WorkingSet -gt 100MB }
C. Select-Process -Memory > 100MB
D. Get-Process -Memory 100MB

12 Which PowerShell Drive (PSDrive) allows direct access to the Windows Registry Local Machine hive?

A. Registry::LocalMachine
B. HKLM:
C. C:\Windows\System32\Config
D. RegLM:

13 Which cmdlet is used to modify a specific value inside a registry key?

A. New-Item
B. Update-Item
C. Set-ItemProperty
D. Set-RegistryKey

14 Which cmdlet is required to enable PowerShell Remoting on a local computer?

A. Enable-PSRemoting
B. Allow-RemoteAccess
C. Set-ExecutionPolicy RemoteSigned
D. Start-Remoting

15 Which cmdlet starts an interactive 1-to-1 remote session with a single computer?

A. New-PSSession
B. Enter-PSSession
C. Invoke-Command
D. Connect-Server

16 What protocol does PowerShell Remoting primarily rely on?

A. RDP
B. FTP
C. Telnet
D. WS-Management (WinRM)

17 Which cmdlet allows you to run a script block on multiple remote computers simultaneously?

A. Start-Job
B. Get-RemoteObject
C. Invoke-Command
D. Enter-PSSession

18 When working with Active Directory in PowerShell, which cmdlet creates a new user account?

A. New-ADUser
B. Create-User
C. Set-ADUser
D. Add-ADUser

19 Which parameter of Get-ADUser allows you to find users based on specific criteria (e.g., Department)?

A. -Query
B. -Search
C. -Where
D. -Filter

20 Which command adds an existing user to an Active Directory security group?

A. Set-ADGroup
B. Add-ADGroupMember
C. Join-ADGroup
D. Update-ADGroup

21 What is the primary benefit of using Start-Job in PowerShell?

A. It automatically schedules the command to run daily.
B. It runs the command with higher privileges.
C. It runs the command in the background without blocking the console.
D. It speeds up the command execution.

22 Which cmdlet retrieves the output data from a completed background job?

A. Receive-Job
B. Show-Job
C. Get-Job
D. Read-Job

23 How do you define a Scheduled Task Action in PowerShell?

A. New-ScheduledTaskAction
B. Start-Task
C. Register-ScheduledTask
D. Set-TaskAction

24 In an Advanced Function, which attribute enables support for common parameters like -Verbose and -WhatIf?

A. [Function()]
B. [CmdletBinding()]
C. [Parameter()]
D. [Advanced()]

25 Which validation attribute ensures a parameter value is selected from a predefined list?

A. [ValidateList()]
B. [ValidateRange()]
C. [ValidatePattern()]
D. [ValidateSet()]

26 How do you make a function parameter mandatory?

A. [ValidateNotNull()]
B. [Required]
C. param(mandatory)
D. [Parameter(Mandatory=$true)]

27 Which .NET class is commonly loaded to create Windows Forms (WinForms) GUIs in PowerShell?

A. PowerShell.Forms
B. System.Windows.GUI
C. System.Windows.Forms
D. System.Drawing.UI

28 When creating a GUI, what method must be called on a Form object to display it to the user?

A. $form.Open()
B. $form.ShowDialog()
C. true
D. $form.Render()

29 In a deployment script, which variable represents the directory where the current script is located?

A. $PWD
B. $HOME
C. $PSHome
D. $PSScriptRoot

30 Which block allows you to handle errors gracefully in automation scripts?

A. do...while
B. error...resume
C. try...catch...finally
D. if...else

31 Which cmdlet is used to write entries to the Windows Event Log?

A. Write-EventLog
B. Set-Event
C. Write-Host
D. Add-LogEntry

32 If you need to verify if a file or folder exists before attempting to copy it, which cmdlet should be used?

A. Find-Path
B. Check-File
C. Test-Path
D. Get-Item

33 In a user management script, how do you generate a random password using a .NET class?

A. Get-Random
B. New-Guid
C. [System.Web.Security.Membership]::GeneratePassword()
D. Convert-SecureString

34 Which operator is used to check if a string matches a Regular Expression (Regex)?

A. -match
B. -eq
C. -like
D. -contains

35 In a monitoring script, if you want to calculate the percentage of free disk space, which formula is correct (conceptually)?

A.
B.
C.
D.

36 What is the purpose of Splatting in PowerShell scripts?

A. To split a string into an array.
B. To pass a collection of parameter values to a command using a hashtable.
C. To delete variables from memory.
D. To format output as a list.

37 When writing an automation script, which variable refers to the current object in the pipeline?

A. $OBJ
B. PSItem
C. $THIS
D. $CURRENT

38 Which XML method would you use to save changes made to an XML object back to a file?

A. Set-Content
B. Export-Clixml
C. Write-Xml
D. $xml.Save("path")

39 What is the difference between Write-Host and Write-Output?

A. Write-Host sends to the console only; Write-Output sends data to the pipeline.
B. Write-Output is deprecated.
C. They are identical.
D. Write-Host sends data to the pipeline; Write-Output sends to the console only.

40 Which cmdlet is used to safely request user credentials (username and password) for a script?

A. Read-Host
B. Get-Credential
C. Input-User
D. Select-User

41 Which parameter is used to dry-run a potentially dangerous command (like deleting users) without actually executing it?

A. -Trial
B. -Test
C. -Confirm
D. -WhatIf

42 To convert a CSV file directly into an HTML report, which pipeline chain is correct?

A. Import-Csv | ConvertTo-Html | Out-File report.html
B. Import-Csv | Export-Html
C. Read-Csv | Out-Html
D. Get-Content | Format-Html

43 Which command is used to reload the current user's profile script after making changes?

A. Reload-Profile
B. Start-Profile
C. . $PROFILE
D. Update-Session

44 In a foreach (users) loop, what does $user represent?

A. The current item being processed in the iteration.
B. A system reserved variable.
C. The entire collection of users.
D. The index of the loop.

45 Which cmdlet creates a new background job specifically for WMI/CIM queries?

A. Invoke-CimMethod
B. Get-WmiJob
C. Get-CimInstance (does not create job by default)
D. Register-WmiEvent

46 Wait, let's refine the previous thought. Which cmdlet allows running a WMI command as a job?

A. Start-Wmi
B. Run-WmiJob
C. Get-WmiObject -AsJob
D. New-WmiJob

47 Which validation attribute is best used to ensure an integer parameter falls between 1 and 100?

A. [ValidateSet(1,100)]
B. [ValidateLength(1,100)]
C. [ValidateRange(1,100)]
D. [ValidateCount(1,100)]

48 How do you create a multiline comment in PowerShell?

A. /* comment */
B. -- comment --
C. <# comment #>
D. // comment //

49 Which Logical Operator represents 'Not Equal' in PowerShell?

A. <>
B. -not
C. !=
D. -ne

50 When deploying a script, how do you bypass the default execution policy restriction for a specific process only?

A. Set-ExecutionPolicy Unrestricted
B. Remove-Item Cert:\LocalMachine
C. powershell.exe -ExecutionPolicy Bypass -File script.ps1
D. Unblock-File script.ps1