Help needed with Get-Random and If Statement

I’m trying to create a scenario where I have a variable that uses Get-Random to pick a number between 1 and 20. I then need to break as k it into if statements. So if number is between 1-10 do action 1. If number is between 11-15 do action 2. If number is between 16-20 do action 3.

Trouble I’m having is with the if statement. I tried If $variable -eq 1-10. But it didn’t work. How do I do this?

Background is that I want 3 things to randomly happen in a for loop. For each loop I want it to pick one of the actions but with preference on action 1 (1-10).

I’m new to coding and powershell so i also won’t if there’s another (easier) way to achieve this?

Thanks for help/guidance.

submitted by /u/-_-welcome1-_-
[link] [comments]

Leave a Reply