As I’m working in PowerShell ISE, I would like to take a quick look at my results in an array or hash table. Here is how to preview part of that.
Here is the array $p with all the Windows svchost processes that I will use for demonstration.
$p = Get-Process svchost
The first item of an array. Indexation starts at 0.
First 5 items of the array.
Last item of the array.
Last 5 items of the array.
Alternatively, you can preview your array in Powershell by using select.
$p | select -First 5 $p | select -Last 5
Most of the time, I like to generate a preview of the array in the PowerShell console. Here are two of the PowerShell ISE shortcuts that I’m using to switch to console and back to the script pane.
Ctrl + D – go to the PowerShell console
Ctrl + I – go to the PowerShell script pane