Unit 6: Advanced PowerShell and Automation - Practice Quiz
1 Which PowerShell cmdlet loads a module into the current session?
2 Which cmdlet lists modules currently imported into a PowerShell session?
3 Which cmdlet imports data from a CSV file as PowerShell objects?
4 Which cmdlet converts a JSON-formatted string into PowerShell objects?
5 What is a common purpose of a menu in a PowerShell script?
6 Which cmdlet prompts a user to enter text in the console?
7 Which cmdlet displays processes running on a computer?
8 Which cmdlet starts a stopped Windows service?
9 Which PowerShell cmdlet retrieves an Active Directory user account?
10
Which PowerShell module commonly provides cmdlets such as Get-ADUser?
11 Which cmdlet runs a command on one or more remote computers?
12 Which cmdlet starts an interactive PowerShell session with a remote computer?
13 Which cmdlet starts a PowerShell command as a background job?
14 Which cmdlet retrieves the results produced by a PowerShell background job?
15 What is the main purpose of a scheduled task?
16 Which attribute restricts a PowerShell parameter to a predefined set of values?
17 Which .NET technology can be used to create graphical interfaces in PowerShell?
18 Why might a user-management script read account details from a CSV file?
19 Which cmdlet retrieves entries from Windows event logs?
20 What is the purpose of a basic system-monitoring script?
21
A script requires the ActiveDirectory module. Which command should be used at the beginning of the script to load the module and stop execution if loading fails?
22
A CSV file contains Name and Enabled columns. Which command imports the file and returns only rows where Enabled is the text value True?
23 A nested PowerShell object is being saved as JSON, but properties below the second level are replaced with abbreviated output. Which command best preserves six levels of nested data?
24
An XML configuration file contains <server enabled="true">APP01</server> inside a <servers> element. After loading it with [xml]$config = Get-Content ./config.xml, which expression selects only enabled server nodes?
25
A console menu accepts choices 1, 2, or Q. Which construct most clearly routes each valid choice to a separate action?
26 A script must request administrator credentials without displaying the password as plain text. Which command is most appropriate?
27 A script must restart the Print Spooler only when it is currently running. Which command sequence meets the requirement?
28
Which command creates or updates the LogLevel DWORD value under HKLM:\Software\Contoso?
29
An administrator must disable all enabled users in the OU=Contractors,DC=example,DC=com organizational unit. Which pipeline performs this task?
30
A command must retrieve the WinRM service from SERVER01 and SERVER02 without creating persistent sessions. Which command should be used?
31 A script runs several commands repeatedly on the same remote computer. Which approach avoids creating a new remote connection for every command?
-Class
-Job
-Transcript
-Session
32 A background job has completed, and its output must be collected while keeping the job available for later inspection. Which command should be used?
33
A PowerShell script must run daily at 2:00 AM under the SYSTEM account. Which set of objects is required before calling Register-ScheduledTask?
34
An advanced function parameter named Environment must accept only Dev, Test, or Prod. Which declaration enforces this rule before the function body runs?
35
A function accepts server names from the pipeline by property name. Which parameter attribute enables objects with a ComputerName property to bind automatically?
36 A Windows Forms button should run code when a user clicks it. Which statement correctly attaches a click event handler?
37 A user-provisioning script imports employee records from CSV. Which design best prevents duplicate Active Directory accounts when the script is run again?
New-ADUser
New-ADUser twice and suppress all errors
38
A log-maintenance script must archive .log files older than 30 days. Which filter correctly identifies the files?
39
A monitoring script samples processor usage and must alert when the average PercentProcessorTime value exceeds 80. Which approach correctly calculates the average from $samples?
40 A deployment script installs an MSI package silently and must wait for installation to finish before verifying the application. Which command is most appropriate?
41
A script module defines Get-Report, New-Report, and Remove-Report. The .psm1 file calls Export-ModuleMember -Function Get-Report,New-Report, while the manifest specifies FunctionsToExport = @('Get-Report','Remove-Report'). Which functions are exported when the manifest is imported?
Get-Report
Get-Report and New-Report
Get-Report and Remove-Report
42
A server has versions 2.1.0 and 3.0.0 of Contoso.Tools installed. A script must load at least version 2.0.0 but must never load version 3.0.0 or later. Which command enforces that requirement?
Import-Module Contoso.Tools -RequiredVersion 2.0.0 -MaximumVersion 2.9.9
Import-Module Contoso.Tools -MinimumVersion 2.0.0 -MaximumVersion 2.9.9
Import-Module Contoso.Tools -Version 2.0.0 -MaximumVersion 2.9.9
Import-Module Contoso.Tools -MinimumVersion 2.0.0 -Force
43
A PowerShell object contains nested properties five levels deep. After ConvertTo-Json and ConvertFrom-Json, properties below the default serialization depth are missing or represented incompletely. Which change directly addresses the problem?
ConvertTo-Json -Compress before writing
ConvertTo-Json -Depth 6 before writing
Export-Csv -NoTypeInformation before writing
ConvertFrom-Json -AsHashtable after reading
44
An XML document uses <d:server> elements under the namespace URI urn:datacenter. Why does Select-Xml -Xml $xml -XPath '//server' return no nodes, and what is the correct approach?
//*:server in every PowerShell version
urn:datacenter
45
A console menu accepts choices 1 through 4. It must reject 2abc, whitespace, and out-of-range integers without throwing an exception. Which validation design is most robust?
[int] and test whether the result is nonzero
-match '[1-4]' and accept any successful match
[int]::TryParse() and then test the parsed range
1 and 4
46
An automation script must prompt interactively for credentials and pass them to Invoke-Command without storing the password as plain text in a variable. Which approach is appropriate?
Read-Host and assign the value directly to -Credential
$Host.UI.ReadLine() and convert it with ConvertFrom-Json
Get-Credential and pass the resulting PSCredential
Read-Host and place the result in a custom object
47
A 64-bit machine has different values in the 32-bit and 64-bit registry views. A 32-bit PowerShell process must reliably modify the 64-bit HKLM\Software view. Which technique is correct?
64bit::HKLM\Software
LocalMachine with Registry64 through Microsoft.Win32.RegistryKey
$Env:PROCESSOR_ARCHITECTURE to AMD64 before writing
HKLM:\Software after calling Set-Location
48 A script locates a process, waits several seconds, and then stops it. Process IDs can be reused during that interval. Which design best reduces the risk of stopping a different process?
Stop-Process -Id later
StartTime before stopping
49 A provisioning script may be rerun after partial failure. It must add a user to a group without failing when the user is already a member. Which pattern is most idempotent?
Add-ADGroupMember and suppress every error
Add-ADGroupMember
Add-ADGroupMember
50
A script must find enabled users under one organizational unit whose Department equals the value in $department, while allowing the domain controller to perform the filtering. Which approach is appropriate?
Get-ADUser -Identity with -SearchScope Subtree and filter locally
Get-ADObject -IncludeDeletedObjects and compare distinguished names
Get-ADUser -Filter with -SearchBase and request needed properties
Get-ADUser -Filter * for the domain and apply two Where-Object calls
51
After Invoke-Command -ComputerName Server1 { Get-Service BITS }, the returned object is labeled Deserialized.System.ServiceProcess.ServiceController, and its service-control methods are unavailable. What explains this behavior?
Get-Service returns method-free objects outside interactive sessions
Microsoft.PowerShell.Management module
52 From workstation A, an administrator remotes to server B. A command on B then attempts to access a protected file share on server C using the administrator's credentials and receives access denied. Which remoting issue is most likely?
53
A script calls Receive-Job $job once for an interim status display and later calls it again after completion, but the first batch of output is missing from the final collection. Which change preserves previously received output?
Get-Job $job -IncludeChildJob for the interim read
Wait-Job $job -Force before the interim read
Receive-Job $job -AutoRemoveJob for the interim read
Receive-Job $job -Keep for the interim read
54 A scheduled PowerShell task must run on a server after reboot even when no user is signed in. It requires elevated local privileges and must not depend on an interactive desktop. Which configuration best meets these requirements?
LOCAL SERVICE with a logon trigger and limited privileges
SYSTEM with RunLevel Highest and a startup trigger
Interactive logon and a boot delay
55
An advanced function accepts server names from the pipeline both by value and by property name. It should collect input in process and perform one batched API call after all pipeline input arrives. Where should the API call be placed?
dynamicparam, after validation attributes are evaluated
begin, before pipeline values have been bound
process, once for every bound pipeline object
end, using values accumulated during process
56 A function parameter must accept only existing leaf files. The function also accepts pipeline input, and validation must occur during parameter binding. Which declaration is most suitable?
[ValidatePattern('.*')][System.IO.FileInfo]$Path
[ValidateScript({ Test-Path $_ -PathType Leaf })][string]$Path
[ValidateRange(1,1)][string]$Path
[ValidateSet('Leaf')][string]$Path
57 A WPF PowerShell tool starts a long-running scan directly in a button click handler, causing the window to freeze. Which architecture keeps the interface responsive and updates controls safely?
Start-Sleep between operations
DoEvents after each result
58 A bulk user-creation script reads a CSV and may stop halfway because of a transient directory failure. Which design most safely supports rerunning the same file?
59 A script polls a growing text log every minute. It must avoid rereading old lines and must also handle log rotation, where the replacement file can be smaller than the previous file. What state should it persist?
60 A monitoring script computes CPU utilization from a cumulative processor-time counter sampled at times and . On an -logical-processor system, which expression gives normalized utilization as a percentage?
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 →