Complete the code to display the PowerShell version using the automatic variable.
Write-Output $[1].PSVersionThe automatic variable $PSVersionTable holds details about the PowerShell version. Accessing PSVersion property shows the version.
Complete the code to output each item in the pipeline using the automatic variable.
Get-Process | ForEach-Object { Write-Output [1] }The automatic variable $_ represents the current object in the pipeline inside script blocks.
Fix the error in the code to correctly display the PowerShell version major number.
Write-Output $PSVersionTable.[1].MajorThe property holding the version object inside $PSVersionTable is PSVersion. Accessing Major gives the major version number.
Fill both blanks to filter processes with CPU time greater than 100 and output their names.
Get-Process | Where-Object { $_.[1] -gt 100 } | ForEach-Object { Write-Output $_.[2] }The CPU property holds the CPU time used by a process. Filtering with -gt 100 selects processes using more than 100 CPU seconds. Then outputting the Name property shows their names.
Fill all three blanks to create a hashtable of process names and their IDs for processes with IDs less than 1000.
Get-Process | Where-Object { $_.[1] [2] 1000 } | ForEach-Object { $result[$_.[3]] = $_.Id }The Id property is used to filter processes with IDs less than 1000 using <. The Name property is used as the key in the hashtable to store process IDs.