Creating parameters with defult values

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
kstemwell
Posts: 14
Last visit: Fri Sep 30, 2022 12:11 pm

Creating parameters with defult values

Post by kstemwell »

:mrgreen: :roll: (*** Please do not write "latest" as a version, specify a version number ***)
PowerShell Studio 2016 5.2.129
32 or 64 bit version of product: 64
Operating system: Windows 10
32 or 64 bit OS: 64
PowerShell Version: 5.1.14393.206

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

I am have been using the 'Edit Parameters' dialog box (which it great by the way) and am trying to create a parameter that works like 'Write-Host -ForegroundColor availablecolors'.

What I mean is when you use the -ForegroundColor switch and use the tap key or drop down (depending on environment) you have the available options of the different default colors.

I want to create a parameter that works just like that.

Is this possible using the 'Edit Parameters' wizard and if so what steps are involved to make this happen?

Thanks
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Creating parameters with defult values

Post by DevinL »

If I understand correctly, you're wanting to use the 'Edit Parameters' dialog to create a window similar to this?
Primal_Sense.png
Primal_Sense.png (7.17 KiB) Viewed 1892 times
If that's what you're trying to achieve, it depends entirely upon where you're wanting this information displayed. My recommendation to you is to use a ValidateSet() and give the parameter a limited set of colors that are available for use.

For example, you can do this in the 'Edit Parameters' dialog like so:
  1. First, you're going to want to add the parameter how you want it, then select edit:
    Edit_Parameter.png
    Edit_Parameter.png (9.49 KiB) Viewed 1892 times
  2. In the resulting dialog, in the Validation panel click Add -> Validate Set:
    Validate_Set.png
    Validate_Set.png (17.86 KiB) Viewed 1892 times
When you get the empty box to appear, enter the possible values line by line and when you save it all, it should work similar to this:
Primal_Sense-2.png
Primal_Sense-2.png (23.69 KiB) Viewed 1892 times
DevinL
SAPIEN Technologies, Inc.
User avatar
kstemwell
Posts: 14
Last visit: Fri Sep 30, 2022 12:11 pm

Re: Creating parameters with defult values

Post by kstemwell »

That is exactly what I need.

Thanks
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Creating parameters with defult values

Post by DevinL »

No problem, I'm glad that's what you needed.

If you have any further issues, please don't hesitate to post again.
DevinL
SAPIEN Technologies, Inc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Creating parameters with defult values

Post by davidc »

If you use the System.Drawing.Color type, PowerShell Studio will automatically list the available colors.
  1. [System.Drawing.Color]$color
This way you don't have to create a ValidationSet.
David
SAPIEN Technologies, Inc.
This topic is 7 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.