Support arrays for types that can be cast from string

Support arrays for types that can be cast from string

1

avatar

By default, strings work fine:

Param([string[]]$AString)

That will pull up the mutliple-selection interface - all good.

if you do this:

Param([mailaddress[]]$AnEmail)

You will only get the option to input a single string. If you provide default parameters, only the first element will be shown in the web interface.

As a string (with valid formatting) can be cast to type [mailaddress], it would be great to support this in the web interface when selecting multiple elements. Obviously ValidateScript is an option from the string input, but being able to use standard powershell conventions would be a lot neater.

I found this, not sure if it's any help: c# - Can I check if a variable can be cast to a specified type? - Stack Overflow

avatar

Recommended Answer

@lloydmitchell This is a good suggestion. I'll open an issue for it so we can track it for a future version. I think it would be good for things like IPAddress etc.

Adam Driscoll
PowerShell Expert and Developer at Devolutions

All Comments (1)

avatar

@lloydmitchell This is a good suggestion. I'll open an issue for it so we can track it for a future version. I think it would be good for things like IPAddress etc.

Adam Driscoll
PowerShell Expert and Developer at Devolutions

Ends in 2 days