I have created an array to store elements of Ids of a Get-Process request.
$arr = [int64[]]::new(1000);
Here is the code to output the data
$process = Get-Process | Where-Object {$_.handles -gt 1000}
I want to select the column for IDs specifically, and here is the code below
$a = $process | Select-Object -Property Id
My question now is how do you store the data for $a
inside the $arr
$a = $process.ID
gives you an array of process ID values. In a pipeline you can also use$process | Select-Object -ExpandProperty ID
or$process | ForEach-Object ID
.Int64
, just do$a = [int64[]]$process.Id
. What would be the point of creating a thousand item array and then trying to insert values into that afterwards?$a = [int64[]](Get-Process | Where-Object {$_.handles -gt 1000}).Id