O'Reilly logo

Windows PowerShell™ 3.0 Step by Step by Ed Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Out-of-bounds errors

When receiving input from a user, an allowed value for a script parameter is limited to a specified range of values. If the allowable range is small, it may be best to present the user with a prompt that allows selection from a few choices. This was shown earlier in this chapter, in the Limiting choices section.

When the allowable range of values is great, however, limiting the choices through a menu-type system is not practical. This is where boundary checking come into play.

Using a boundary-checking function

One technique is to use a function that will determine if the supplied value is permissible. One way to create a boundary-checking function is to have the script create a hash table of permissible values. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required