Error message
Better error messages for PowerShell ValidatePattern
By Joel 'Jaykul' Bennett on 15-Jun-2010
If you’ve been writing advanced PowerShell 2.0 functions, you’ve probably used some of the Validate* attributes to enforce valid parameter values, and you may have noticed that their error messages leave a lot to be desired. For example, imagine that you have a parameter which takes a 10-digit phone number: function Test-PhoneNumber { param( [ValidatePattern(’^\(?\d{3}\)?\s.]?\d{3}[\s.]\d{4}$’)]$number [...]
Posted in Huddled | Tagged Attribute, Error message, PowerShell, ValidatePattern | 3 Responses
Another Module Manifest Gotcha
By Joel 'Jaykul' Bennett on 14-Jan-2010
Shay Levy, ScriptFanatic, wrote about the PowerShellHostVersion on his blog this morning, explaining how it is not a field you should use in your module manifests. Of course, there’s an exception: if your module is dependent on a specific host. For instance, if you’ve written a module for PoshConsole which exploits the WpfHost display features [...]
Posted in Huddled | Tagged Error message, Globally Unique Identifier, Import-Module, Metadata, Modules, PowerShell, RequiredModules | 1 Response