title: Powershell: How to Validate Range between 1 to 15 and it should accepts pattern as 1,2,3,4,5 to 15
body: <p>I am a newbie in Power Shell Scripting.
  I am trying to Achieve a functionality, that should accepts inputs from user in below criteria </p>
  
  <ol>
  <li>Only Digits</li>
  <li>Range Between 1 to 15</li>
  <li>Should accept String of Array with comma Separated values ex: 1,2,3,4,14,15</li>
  <li>Can Contain space in between commas</li>
  <li>Values should not be duplicated</li>
  <li>The Returned values must be Array</li>
  </ol>
  
  <p>Till now, I have tried</p>
  
  <pre><code>Function Validate-Choice{
  [cmdletbinding()]
  Param(
  [Parameter(Position=0,Mandatory=$True)]
  [ValidateRange(1,15)]
  [string[]]$Item
  )
  Process {$Item}
  }
  Validate-Choice 1,2,3,4,5,6,7,8,9,10,11,13 # Similar Way i want O/p
  
  Out Put: 
       1
       2
       3
       4
       5
       6
       7
       8
       9
       10
       11
       13
  
  
   $ReadInput = Read-Host  -prompt "Please Choose from the list [1/2/3/4/5/6/7/8/9/10/11/12/13/14] You can select multiple Values  EX: 1, 2, 3 --  "
   $userchoices = Validate-Choice -item $ReadInput
   $userchoices
  
  If read the same input from Host Getting Below Error
  
  Validate-Choice : Cannot validate argument on parameter 'Item'. The argument    cannot be validated because 
  its type "String" is not the same type (Int32) as the maximum and minimum limits of the parameter. Make sure the argument is of type Int32 and then try  the command again. At line:10 char:21
  +     Validate-Choice '1,2,3,4,5,6,7,8,9,10,11,13'
  +                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : InvalidData: (:) [Validate-Choice],   ParameterBindingValidationException
  + FullyQualifiedErrorId : ParameterArgumentValidationError,Validate-Choice
  </code></pre>
  
  <p>And  also i am trying with different Regex patterns. But failing</p>
  
  <pre><code>Function Test-Something {
  [cmdletbinding()]
  Param(
      [Parameter(Position=0,Mandatory=$True)]
      [ValidatePattern('(?:\s*\d{1,15}[1-15]\s*(?:,|$))+$')]
      [string[]]$Item
  )
  Process { $Item }
  }
  </code></pre>
  
  <p>The above functions are partially resulting.
  Can any one please help me here..!?</p>