SpecOps icon indicating copy to clipboard operation
SpecOps copied to clipboard

Using the Menu ID in the script

Open jeff-estes-saggs opened this issue 3 years ago • 1 comments

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.

jeff-estes-saggs avatar Oct 11 '22 20:10 jeff-estes-saggs

There's two different ways you could pretty easily add the scriptId to the list of parameters available within the powershell script:

  1. 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);
  1. 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-

KennethScott avatar Oct 13 '22 02:10 KennethScott

Hey sorry it's taken so long, but I've just posted a new release that has the SpecOpsScriptId parameter we discussed. Thanks!

KennethScott avatar Dec 23 '22 06:12 KennethScott