Roll Dice With Get-Random
Simulate one or more dice rolls with a cryptographically seeded RNG.
Run Get-Random -Minimum 1 -Maximum 7 to roll a single six-sided die.
01Command
Command
$ Get-Random -Minimum 1 -Maximum 702What it does
Get-Random returns a random value; the upper bound is exclusive, so Maximum 7 yields 1 through 6. Pipe a range into it or loop to roll several dice, for example 1..2 | ForEach-Object { Get-Random -Minimum 1 -Maximum 7 }.
03Risk
!Warning: For security-sensitive randomness use -SetSeed never; the default already uses a strong generator, but avoid predictable seeds.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Get-RandomEvidence: Documents -Minimum/-Maximum ranges and collection selection.
Last verified: 2026-09-20 · Category: Developer
06Related solutions
Grep on Windows: Select-String
Search inside text files and logs with regex, returning file, line number and match.
Zip Files with Compress-Archive
Create or update a .zip from any files or folder contents straight from PowerShell.
Test a TCP port connection on Windows with Test-NetConnection
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.