Skip to content

Add a -Shuffle switch to Get-Random for convenient collection shuffling #11022

@mklement0

Description

@mklement0

Summary of the new feature/enhancement

Get-Random currently requires you to specify a -Count argument in order to extract a random subset from an input collection.

Sometimes you want to shuffle an input collection, i.e. to return all input objects, in randomized order, and it would be nice to be able to express that intent directly, without having to provide a -Count (which may not even be known; you can work around that with -Count ([int]::MaxValue), but that is awkward).

To that end, a new -Shuffle parameter could be introduced:

# WISHFUL THINKING - sample output.
PS> 1..5 | Get-Random -Shuffle
4
2
5
3
1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions