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.
User avatar
bgleason
Posts: 29
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Mon Jul 14, 2014 1:35 pm

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.  
  3.     if ($ScaleMethod -eq "AutoStatic") {
  4.  
  5.       $attThreashold = New-Object System.Management.Automation.ParameterAttribute
  6.  
  7.       $attThreashold.Mandatory = $true
  8.  
  9.       $attributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
  10.  
  11.       $attributeCollection.Add($attThreashold)
  12.  
  13.       $paramThreshold = New-Object System.Management.Automation.RuntimeDefinedParameter('Threshold', [Int], $attributeCollection)
  14.  
  15.       $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
  16.  
  17.       $paramDictionary.Add('Threshold', $paramThreshold)
  18.  
  19.       return $paramDictionary
  20.  
  21.     }
  22.  
  23.   }
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 502 times

User avatar
Alexander Riedel
Posts: 7342
Joined: Tue May 29, 2007 4:43 pm

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
Joined: Mon Jul 14, 2014 1:35 pm

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 445 times
Threshold-No.png
Threshold-No.png (25.36 KiB) Viewed 445 times

User avatar
Alexander Riedel
Posts: 7342
Joined: Tue May 29, 2007 4:43 pm

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
Joined: Mon Jul 14, 2014 1:35 pm

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
Joined: Mon Jul 14, 2014 1:35 pm

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
Joined: Mon Jul 14, 2014 1:35 pm

Re: dynamicparam Support

Post by bgleason »

Anything further on this...??

User avatar
Alexander Riedel
Posts: 7342
Joined: Tue May 29, 2007 4:43 pm

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.