PowerShell Suppress Output

powershell

Solution

Remove `int[]] $randomNumbers;`. It is not the assignment that is printed, but the empty array.

Problem

I've checked and tried a few of the suggestions on StackOverflow but none of them seem to work. I put together an example of what I am trying to accomplish. ``` [System.Random] $rand = New-Object System.Random $randomNumbers = New-Object int[] 10; [int[]] $randomNumbers; for($i = 0; $i -lt $randomNumbers.Length; $i++) { ($randomNumbers[$i] = $rand.Next(256)) 2>&1 | Out-Null; } ``` I've tried the ``` > $Null |Out-Null 2>&1 ``` But none of them seem to suppress the output. It's showing 10 zero's in a row. One for each assignment. How can I suppress that output?

Original source