Adding an array element infront of array string

Hi All.

I want to try and create a loop where when the array gets to the bottom of the array, the first element of the array is added to the front and the loop continues, then the second, third, until that 2x array loop ends, then it starts again with a 3rd element.

the idea was to effecively try to replicate a brute force attack using powershell.

I know i can just use a password file or create something that contains a limited number of the files, but its a theoretical challenge thats got me wondering how to do it.

anyone have any ideas on how to loop and add the array together so that in theory you could (if it ran for long enough) have a infinite loop (until running out of memory or run-time between reboots).

Hi, welcome to the forum :wave:

Not 100% sure I’ve understood the requirement. If you just want to loop over an array in an infinite manner then this will do it:

$array = @(1,2)
while ($true) { $array }

If you can provide more detail about what you’re trying to do, or share some code of things you’ve tried already, perhaps we can help further.