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

Incorrect data types

There are two approaches to ensuring that your users only enter allowed values for the script parameters. The first is to offer only a limited number of values. The second approach allows the user to enter any value for the parameter. It is then determined if the value is valid before it is passed along to the remainder of the script. In the Get-ValidWmiClassFunction.ps1 script, which follows, a function named Get-ValidWmiClass is used to determine if the value that is supplied to the script is a legitimate WMI class name. In particular, the Get-ValidWmiClass function is used to determine if the string that is passed via the -class parameter can be cast to a valid instance of the System.Management.ManagementClass .NET Framework ...

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