Unit 6: Advanced PowerShell and Automation - Practice Quiz
1 Which PowerShell cmdlet is primarily used to load a module into the current session?
Load-Module
Import-Module
Get-Module
Install-Module
2 Which environment variable stores the paths where PowerShell looks for modules?
$env:PSModulePath
$env:PSHome
$env:Path
$env:ModulePath
3 What is the file extension for a PowerShell Module Manifest file?
.psd1
.psm1
.ps1
.xml
4 Which cmdlet is used to import data from a Comma-Separated Value file and create objects from it?
Import-Csv
Read-Csv
ConvertFrom-Csv
Get-Content
5 When converting a PowerShell object to JSON format, which cmdlet is used?
Out-Json
Export-Json
Format-Json
ConvertTo-Json
6 Which cmdlet allows you to read an XML file and navigate its nodes as properties?
Get-Content -AsXml
Import-Xml
Select-Xml
[xml](Get-Content path)
7 Which cmdlet is most appropriate for prompting a user to input a password securely?
Get-Credential
Read-Host -AsSecureString
Read-Host -MaskInput
Read-Input -Secure
8 Which cmdlet creates a graphical window allowing users to select one or more items from a list?
Out-GridView -PassThru
Select-Object -UI
Read-Choice
Show-Menu
9 In a text-based menu script, which statement is most efficient for handling multiple specific user choices?
switch
while
if...else
foreach
10 Which cmdlet is used to stop a running Windows service?
Kill-Service
Stop-Service
End-Service
Disable-Service
11 To retrieve a list of all processes currently consuming more than 100MB of memory, which command structure is correct?
Get-Process -Memory 100MB
Select-Process -Memory > 100MB
Get-Process | Filter-Object { $_.Memory -gt 100MB }
Get-Process | Where-Object { $_.WorkingSet -gt 100MB }
12 Which PowerShell Drive (PSDrive) allows direct access to the Windows Registry Local Machine hive?
HKLM:
RegLM:
Registry::LocalMachine
C:\Windows\System32\Config
13 Which cmdlet is used to modify a specific value inside a registry key?
New-Item
Set-RegistryKey
Update-Item
Set-ItemProperty
14 Which cmdlet is required to enable PowerShell Remoting on a local computer?
Set-ExecutionPolicy RemoteSigned
Start-Remoting
Allow-RemoteAccess
Enable-PSRemoting
15 Which cmdlet starts an interactive 1-to-1 remote session with a single computer?
Enter-PSSession
New-PSSession
Connect-Server
Invoke-Command
16 What protocol does PowerShell Remoting primarily rely on?
17 Which cmdlet allows you to run a script block on multiple remote computers simultaneously?
Get-RemoteObject
Start-Job
Enter-PSSession
Invoke-Command
18 When working with Active Directory in PowerShell, which cmdlet creates a new user account?
Set-ADUser
Create-User
Add-ADUser
New-ADUser
19
Which parameter of Get-ADUser allows you to find users based on specific criteria (e.g., Department)?
-Where
-Search
-Query
-Filter
20 Which command adds an existing user to an Active Directory security group?
Add-ADGroupMember
Update-ADGroup
Join-ADGroup
Set-ADGroup
21
What is the primary benefit of using Start-Job in PowerShell?
22 Which cmdlet retrieves the output data from a completed background job?
Show-Job
Read-Job
Get-Job
Receive-Job
23 How do you define a Scheduled Task Action in PowerShell?
Start-Task
Set-TaskAction
Register-ScheduledTask
New-ScheduledTaskAction
24
In an Advanced Function, which attribute enables support for common parameters like -Verbose and -WhatIf?
[CmdletBinding()]
[Parameter()]
[Advanced()]
[Function()]
25 Which validation attribute ensures a parameter value is selected from a predefined list?
[ValidateRange()]
[ValidatePattern()]
[ValidateList()]
[ValidateSet()]
26 How do you make a function parameter mandatory?
[Parameter(Mandatory=$true)]
[Required]
param($path = $mandatory)
[ValidateNotNull()]
27 Which .NET class is commonly loaded to create Windows Forms (WinForms) GUIs in PowerShell?
System.Drawing.UI
System.Windows.GUI
System.Windows.Forms
PowerShell.Forms
28 When creating a GUI, what method must be called on a Form object to display it to the user?
$form.Open()
$form.ShowDialog()
$form.Render()
$form.Visible = $true
29 In a deployment script, which variable represents the directory where the current script is located?
$PWD
$PSScriptRoot
$HOME
$PSHome
30 Which block allows you to handle errors gracefully in automation scripts?
if...else
try...catch...finally
error...resume
do...while
31 Which cmdlet is used to write entries to the Windows Event Log?
Add-LogEntry
Write-EventLog
Set-Event
Write-Host
32 If you need to verify if a file or folder exists before attempting to copy it, which cmdlet should be used?
Get-Item
Find-Path
Check-File
Test-Path
33 In a user management script, how do you generate a random password using a .NET class?
Convert-SecureString
[System.Web.Security.Membership]::GeneratePassword()
New-Guid
Get-Random
34 Which operator is used to check if a string matches a Regular Expression (Regex)?
-like
-eq
-contains
-match
35 In a monitoring script, if you want to calculate the percentage of free disk space, which formula is correct (conceptually)?
36 What is the purpose of Splatting in PowerShell scripts?
37 When writing an automation script, which variable refers to the current object in the pipeline?
$THIS
$OBJ
$_ or $PSItem
$CURRENT
38 Which XML method would you use to save changes made to an XML object back to a file?
$xml.Save("path")
Set-Content
Write-Xml
Export-Clixml
39
What is the difference between Write-Host and Write-Output?
Write-Host sends data to the pipeline; Write-Output sends to the console only.
Write-Host sends to the console only; Write-Output sends data to the pipeline.
Write-Output is deprecated.
40 Which cmdlet is used to safely request user credentials (username and password) for a script?
Select-User
Input-User
Get-Credential
Read-Host
41 Which parameter is used to dry-run a potentially dangerous command (like deleting users) without actually executing it?
-Test
-Confirm
-Trial
-WhatIf
42 To convert a CSV file directly into an HTML report, which pipeline chain is correct?
Read-Csv | Out-Html
Import-Csv | Export-Html
Import-Csv | ConvertTo-Html | Out-File report.html
Get-Content | Format-Html
43 Which command is used to reload the current user's profile script after making changes?
Reload-Profile
Start-Profile
. $PROFILE
Update-Session
44
In a foreach ($user in $users) loop, what does $user represent?
45 Which cmdlet creates a new background job specifically for WMI/CIM queries?
Get-WmiJob
Get-CimInstance (does not create job by default)
Invoke-CimMethod
Register-WmiEvent
46 Wait, let's refine the previous thought. Which cmdlet allows running a WMI command as a job?
Start-Wmi
Get-WmiObject -AsJob
New-WmiJob
Run-WmiJob
47 Which validation attribute is best used to ensure an integer parameter falls between 1 and 100?
[ValidateSet(1,100)]
[ValidateCount(1,100)]
[ValidateLength(1,100)]
[ValidateRange(1,100)]
48 How do you create a multiline comment in PowerShell?
// comment //
<# comment #>
/* comment */
-- comment --
49 Which Logical Operator represents 'Not Equal' in PowerShell?
-ne
!=
-not
<>
50 When deploying a script, how do you bypass the default execution policy restriction for a specific process only?
Unblock-File script.ps1
Remove-Item Cert:\LocalMachine
Set-ExecutionPolicy Unrestricted
powershell.exe -ExecutionPolicy Bypass -File script.ps1
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →