Flip a Coin With Get-Random

Pick heads or tails at random with a one-line command.

WindowsrandomscriptingpowershellLow risk
Run Get-Random -InputObject @("Heads","Tails") to flip a coin.

01Command

Command
$ Get-Random -InputObject @("Heads","Tails")

02What it does

Besides numeric ranges, Get-Random can select a random element from any collection via -InputObject. Wrap the choices in an array and it becomes a coin flip, a random menu pick or a simple decision helper.

03Risk

RiskLow risk
RequirementsWindows 10/11 with PowerShell 5.1 or PowerShell 7+
!Warning: The result is random but not secret; do not use it to generate cryptographic choices.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Get-Random
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Documents -InputObject, which picks a random item from a collection.

Last verified: 2026-09-20 · Category: Developer

06Related solutions