title: How can ensure that a function only accepts a positive integer?
body: <p>I want to do some basic validation on a user input in PowerShell to ensure a user can only enter a whole integer and does not enter -7 for example. I am not sure how this is done and would appreciate a pointer. </p>
  
  <pre><code>[parameter(Mandatory=$false)][int]$number
  </code></pre>
  
  <p>If a user enters <code>-$number</code> this will be accepted. I want it to reject this type of input. </p>