Using the Menu ID in the script
Is there any way to get the ScriptID as a param in the script. An example if you have one would be great. Trying to use one script but with a switch statement based on the scriptID or even name. Each menu item would be its own function module.
There's two different ways you could pretty easily add the scriptId to the list of parameters available within the powershell script:
- Server-side in the StreamPowerShell method. If you'll notice I'm already explicitly adding 2 parameters for SpecOpsCurrentUser and SpecOpsCurrentUserIP. You'd just add another for the scriptId which is already available as a parameter being passed into that method.
scriptParameters.Add("SpecOpsScriptId", scriptId);
- Client-side in Scripts.cshtml in the on click handler for the runScript button. You'd just need to add the scriptId to the parameters collection being created there like:
parameters["SpecOpsScriptId"] = $('#ScriptId').val();
I've got a growing little to-do list of things for the app I've been trying to find some time to work on. I'll make a note to add it server-side like I did the CurrentUser and CurrentUserIP when I get a chance. Worst case you should be able to just edit the cshtml file and get it going for now though. Hope it helps-
Hey sorry it's taken so long, but I've just posted a new release that has the SpecOpsScriptId parameter we discussed. Thanks!