dynamicparam Support

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 3 years and 10 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
bgleason
Posts: 29
Last visit: Mon Oct 30, 2023 11:35 am
Been upvoted: 2 times

dynamicparam Support

Post by bgleason »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.174
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.18363.0

*** Please add details and screenshots as needed below. ***

Is there any plan for PSS to support dynamicparam. I see that question was kind of asked some time ago:
viewtopic.php?p=60862#p60862
  1.   dynamicparam {
  2.     if ($ScaleMethod -eq "AutoStatic") {
  3.       $attThreashold = New-Object System.Management.Automation.ParameterAttribute
  4.       $attThreashold.Mandatory = $true
  5.       $attributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
  6.       $attributeCollection.Add($attThreashold)
  7.       $paramThreshold = New-Object System.Management.Automation.RuntimeDefinedParameter('Threshold', [Int], $attributeCollection)
  8.       $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
  9.       $paramDictionary.Add('Threshold', $paramThreshold)
  10.       return $paramDictionary
  11.     }
  12.   }
Didn't really go anywhere it seems... To reiterate the prior post, ISE Supports it, just wondering what the challenges are in PSS, if any...?

Thanks!!

DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
Attachments
Threshold.png
Threshold.png (20.79 KiB) Viewed 3027 times
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: dynamicparam Support

Post by Alexander Riedel »

Well, it is basically a chicken - egg problem. The parameters, the name 'dynamicparam' implies, are defined at runtime. So nobody can know what the parameters will be until the script runs. We do not run your script just to determine such things, that would be a huge security hole.
Even if (and that would be a bad idea) we would use the data from the last execution of the script, there is no guarantee whatsoever that conditions would be the same, resulting in the same set of dynamic parameters.
So I am not quite sure what you mean by 'supporting' this. Can you please elaborate?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
bgleason
Posts: 29
Last visit: Mon Oct 30, 2023 11:35 am
Been upvoted: 2 times

Re: dynamicparam Support

Post by bgleason »

Without providing more images, I will try to provide context...

When you are coding in the PSS ide, you can see my -ScaleValue and -ScaleMethod are detected parameters for the function/cmdlet I am calling, and you parse those the moment they are created and the file is saved, it is like PSS, parses through and says, "Yep, for the function I see, those are valid parameters", but it does not do that for dynamicparams... For ex. if you are typing your function, "Doing-Something" followed with a "-" to list your available parameters, only the "params" values are available... Now if I was working in ISE as my IDE, it does support the parsing of dynamicparm values where if I was to bring us a parameters list by typing the "-" after my function name, it would be listed...

Actually, added the images.. The thing that is interesting is also how ISE is showing CMDletBindings re. WhatIf and Confirm, where PSS is not...
Attachments
Threshold-yes.png
Threshold-yes.png (77.97 KiB) Viewed 2970 times
Threshold-No.png
Threshold-No.png (25.36 KiB) Viewed 2970 times
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: dynamicparam Support

Post by Alexander Riedel »

Check if the ISE shows your dynamic parameters just after you launched it or only after you ran that script at least once please.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
bgleason
Posts: 29
Last visit: Mon Oct 30, 2023 11:35 am
Been upvoted: 2 times

Re: dynamicparam Support

Post by bgleason »

Sorry for the late reply...

I open a fresh instance of ISE, copy my code out of PSS, paste it into ISE and my dynamicparam is supported without having to save or run the script...

Thanks,

Brian
User avatar
bgleason
Posts: 29
Last visit: Mon Oct 30, 2023 11:35 am
Been upvoted: 2 times

Re: dynamicparam Support

Post by bgleason »

I saw today that -WhatIf and -Confirm, sorry about that miss, they are just down at the bottom of the params list, still not supporting dynamicparam though.. ;)

Thanks,

Brian
User avatar
bgleason
Posts: 29
Last visit: Mon Oct 30, 2023 11:35 am
Been upvoted: 2 times

Re: dynamicparam Support

Post by bgleason »

Anything further on this...??
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: dynamicparam Support

Post by Alexander Riedel »

We have added it to the list of things to do. I honestly cannot tell you when this will be looked at, it will not be next week though. :D
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 3 years and 10 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.