Random Numbers in PowerShell

Have you ever wondered how to get a random Beatles member in PowerShell?

Daniele Quero, PhD
Geek Culture

--

Photo from https://www.shutterstock.com/image-vector/abstract-background-random-numbers-gray-scale-244169761

Do you need to generate random numbers in your PowerShell script?

That’s how you do it! (for any version from 5.1 on)

PowerShell Provides a simple cmdlet, Get-Random.

Let’s look at these examples to know it better:

So, it’s enough to provide floating-point limits to get a floating-point number.

Limits are excluded!

But PowerShell allows very specific features, and interesting at that! Have you ever wondered how to get a random Beatles member?

The answer is piping a list to the Get-Random cmdlet! You can also ask to extract more than one using the -Count N option.

--

--

Daniele Quero, PhD
Geek Culture

A professional developer with passion for game developing and skill-growing. A former Nuclear Physics Researcher who changed his life to pursue his dreams