Private/Get-RPSUserSelection.ps1
function Get-RPSUserSelection { [CmdletBinding()] [Alias()] [OutputType([Choice])] Param ( ) Begin { } Process { do { $userChoice = Read-Host -Prompt 'Enter choice: (R)ock, (P)aper, (S)cissors'; switch ($userChoice) { 'R'{ return [Choice]::Rock } 'P'{ return [Choice]::Paper } 'S'{ return [Choice]::Scissors } default {} } } while ( $userChoice -notcontains @('R','P','S') ) } End { } } enum Choice { Rock = 0 Paper = 1 Scissors = 2 } |