Flip a Coin With Get-Random
Pick heads or tails at random with a one-line command.
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
!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-RandomEvidence: Documents -InputObject, which picks a random item from a collection.
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.