Restrict Input to Numeric Ranges

by Aug 27, 2010

Let's say you'd like to set the PowerShell console cursor size. This size must be a number between 0 and 100. The following template will validate that the user cannot specify an argument outside the allowed range:

function Set-CursorSize {

$Host.UI.RawUI.CursorSize = $Percent

Twitter This Tip! ReTweet this Tip!