[GH-ISSUE #702] Expose script parameters in Run dialogs #446

Closed
opened 2026-03-02 02:16:25 +03:00 by kerem · 15 comments
Owner

Originally created by @silversword411 on GitHub (Sep 10, 2021).
Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/702

Originally assigned to: @sadnub on GitHub.

Can never remember what the command parameters are for scripts.

Option 1
Add a new item in the .json tip and show under script name selection. In this example I tried to emulate powershell notation (successfully=unsure)
Maybe call it "syntax"? Eg

,
  {
    "guid": "6c78eb04-57ae-43b0-98ed-cbd3ef9e2f80",
    "filename": "Win_Chocolatey_Manage_Apps_Bulk.ps1",
    "submittedBy": "https://github.com/silversword411",
    "name": "Chocolatey - Install, Uninstall and Upgrade Software",
    "description": "This script installs, uninstalls and updates software using Chocolatey with logic to slow tasks to minimize hitting community limits. Mode install/uninstall/upgrade Hosts x",
    "syntax": "[[Mode] {install,uninstall,upgrade}] [[Hosts] <string>]"
    "shell": "powershell",
    "category": "TRMM (Win):3rd Party Software>Chocolatey",
    "default_timeout": "600"
  }

Option 2
Display the description I can work on a standardized format for parameters. Support for new line (with /n?) a bonus.

2021-09-10_074601 - trmm script descriptions1

2021-09-10_074601 - trmm script descriptions2

Originally created by @silversword411 on GitHub (Sep 10, 2021). Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/702 Originally assigned to: @sadnub on GitHub. Can never remember what the command parameters are for scripts. Option 1 Add a new item in the .json tip and show under script name selection. In this example I tried to emulate powershell notation (successfully=unsure) Maybe call it "syntax"? Eg ``` , { "guid": "6c78eb04-57ae-43b0-98ed-cbd3ef9e2f80", "filename": "Win_Chocolatey_Manage_Apps_Bulk.ps1", "submittedBy": "https://github.com/silversword411", "name": "Chocolatey - Install, Uninstall and Upgrade Software", "description": "This script installs, uninstalls and updates software using Chocolatey with logic to slow tasks to minimize hitting community limits. Mode install/uninstall/upgrade Hosts x", "syntax": "[[Mode] {install,uninstall,upgrade}] [[Hosts] <string>]" "shell": "powershell", "category": "TRMM (Win):3rd Party Software>Chocolatey", "default_timeout": "600" } ``` Option 2 Display the description I can work on a standardized format for parameters. Support for new line (with /n?) a bonus. ![2021-09-10_074601 - trmm script descriptions1](https://user-images.githubusercontent.com/13395348/132850282-9bc50a3e-404b-4590-8367-4b461e918882.png) ![2021-09-10_074601 - trmm script descriptions2](https://user-images.githubusercontent.com/13395348/132850295-fc303977-b626-4c5b-9faa-70873d486e5c.png)
kerem 2026-03-02 02:16:25 +03:00
Author
Owner

@bradhawkins85 commented on GitHub (Sep 14, 2021):

This will add script arguments to the community scripts json

"args": [
  "-serviceName {{client.ScreenConnectService}}",
  "-url {{client.ScreenConnectInstaller}}",
  "-clientname {{client.name}}",
  "-sitename {{site.name}}",
  "-action install"
],

They will be pre-filled then, you can just remove and re-add to change the values.

May not achieve exactly what you want but will serve as a workaround for the short term.

<!-- gh-comment-id:919062730 --> @bradhawkins85 commented on GitHub (Sep 14, 2021): This will add script arguments to the community scripts json "args": [ "-serviceName {{client.ScreenConnectService}}", "-url {{client.ScreenConnectInstaller}}", "-clientname {{client.name}}", "-sitename {{site.name}}", "-action install" ], They will be pre-filled then, you can just remove and re-add to change the values. May not achieve exactly what you want but will serve as a workaround for the short term.
Author
Owner

@silversword411 commented on GitHub (Sep 15, 2021):

Would probably work just dandy :)

Gonna be a booger to write the defaults, lots of different scripts with different defaults.

@bradhawkins85 Can you think of how to write up something similar to the powershell syntax that would be TRMM specific (looking for something for the docs).

I look at this

SYNTAX
    Get-Help [[-Name] <string>] [-Path <string>] [-Category {Alias | Cmdlet | Provider | General | FAQ | Glossary | 
    HelpFile | ScriptCommand | Function | Filter | ExternalScript | All | DefaultHelp | Workflow | DscResource | 
    Class | Configuration}] [-Component <string[]>] [-Functionality <string[]>] [-Role <string[]>] [-Full]  
    [<CommonParameters>]

and only when I get it color-coded in VSCode does it help to be more readable (for me at least)

2021-09-14_225634 - powershell command syntax map
<!-- gh-comment-id:919659127 --> @silversword411 commented on GitHub (Sep 15, 2021): Would probably work just dandy :) Gonna be a booger to write the defaults, lots of different scripts with different defaults. @bradhawkins85 Can you think of how to write up something similar to the powershell syntax that would be TRMM specific (looking for something for the docs). I look at this ```powershell SYNTAX Get-Help [[-Name] <string>] [-Path <string>] [-Category {Alias | Cmdlet | Provider | General | FAQ | Glossary | HelpFile | ScriptCommand | Function | Filter | ExternalScript | All | DefaultHelp | Workflow | DscResource | Class | Configuration}] [-Component <string[]>] [-Functionality <string[]>] [-Role <string[]>] [-Full] [<CommonParameters>] ``` and only when I get it color-coded in VSCode does it help to be more readable (for me at least) <img width="683" alt="2021-09-14_225634 - powershell command syntax map" src="https://user-images.githubusercontent.com/13395348/133363100-73faa061-f25e-400a-8931-c6b0176b51a5.png">
Author
Owner

@silversword411 commented on GitHub (Sep 15, 2021):

As an example what would the one for https://github.com/wh1te909/tacticalrmm/blob/develop/scripts/Win_Chocolatey_Manage_Apps_Bulk.ps1

Look like?

<!-- gh-comment-id:919659684 --> @silversword411 commented on GitHub (Sep 15, 2021): As an example what would the one for https://github.com/wh1te909/tacticalrmm/blob/develop/scripts/Win_Chocolatey_Manage_Apps_Bulk.ps1 Look like?
Author
Owner

@silversword411 commented on GitHub (Sep 15, 2021):

So trying to follow powershell's example from here: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_command_syntax?view=powershell-7.1

<command-name> -<Required Parameter Name> <Required Parameter Value>
[-<Optional Parameter Name> <Optional Parameter Value>]
[-<Optional Switch Parameters>]
[-<Optional Parameter Name>] <Required Parameter Value>

TRMM Standard json format would look something like:

"args": [
  "[-Hosts <string>]",   <- optional because surrounded by []
  "-$PackageName <string>",    <----required because no []
  "[-mode {(install) | update | uninstall}]"
],

eg for https://github.com/wh1te909/tacticalrmm/blob/develop/scripts/Win_User_Create.ps1
json would be

"args": [
  "-username <string>",
  "-password <string>",
  "[-description <string>]",
  "[-fullname <string>]",
  "[-group <string>]"
],

So TRMM docs description on a structured format should be:

"args": [
  "[-<Optional Parameter Name> <string>]",
  "-<Required Parameter Name> <string>",
  "[-<string> {(<default string if not specified>) | <string2> | <string3>}]"
],

Anyone see any problems?

<!-- gh-comment-id:919678332 --> @silversword411 commented on GitHub (Sep 15, 2021): So trying to follow powershell's example from here: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_command_syntax?view=powershell-7.1 ```powershell <command-name> -<Required Parameter Name> <Required Parameter Value> [-<Optional Parameter Name> <Optional Parameter Value>] [-<Optional Switch Parameters>] [-<Optional Parameter Name>] <Required Parameter Value> ``` TRMM Standard json format would look something like: ``` "args": [ "[-Hosts <string>]", <- optional because surrounded by [] "-$PackageName <string>", <----required because no [] "[-mode {(install) | update | uninstall}]" ], ``` eg for https://github.com/wh1te909/tacticalrmm/blob/develop/scripts/Win_User_Create.ps1 json would be ``` "args": [ "-username <string>", "-password <string>", "[-description <string>]", "[-fullname <string>]", "[-group <string>]" ], ``` So TRMM docs description on a structured format should be: ``` "args": [ "[-<Optional Parameter Name> <string>]", "-<Required Parameter Name> <string>", "[-<string> {(<default string if not specified>) | <string2> | <string3>}]" ], ``` Anyone see any problems?
Author
Owner

@dinger1986 commented on GitHub (Sep 15, 2021):

looks right to me using that script as an example

<!-- gh-comment-id:919766780 --> @dinger1986 commented on GitHub (Sep 15, 2021): looks right to me using that script as an example
Author
Owner

@silversword411 commented on GitHub (Sep 21, 2021):

This commit is a test of the concept. Not sure how it'll go, can back it out if necessary.

github.com/wh1te909/tacticalrmm@8f9ad15108

<!-- gh-comment-id:923827316 --> @silversword411 commented on GitHub (Sep 21, 2021): This commit is a test of the concept. Not sure how it'll go, can back it out if necessary. https://github.com/wh1te909/tacticalrmm/commit/8f9ad15108441bf373062f43c5810e10937f02a9
Author
Owner

@sadnub commented on GitHub (Oct 11, 2021):

This will break the existing arg functionality since that arg file is copied right to the script default args. Can we use another field like "help" or "syntax"?

<!-- gh-comment-id:940207378 --> @sadnub commented on GitHub (Oct 11, 2021): This will break the existing arg functionality since that arg file is copied right to the script default args. Can we use another field like "help" or "syntax"?
Author
Owner

@silversword411 commented on GitHub (Oct 11, 2021):

@sadnub I was working around not having another field added to the run script like: help/syntax etc.

See the "rename computer" script from the library in the current TRMM v0.8.5. If you wanted to have a new field I can definitely not do this, and put it into a dedicated new field loaded from the json (probably better anyway).

<!-- gh-comment-id:940379170 --> @silversword411 commented on GitHub (Oct 11, 2021): @sadnub I was working around not having another field added to the run script like: help/syntax etc. See the "rename computer" script from the library in the current TRMM v0.8.5. If you wanted to have a new field I can definitely not do this, and put it into a dedicated new field loaded from the json (probably better anyway).
Author
Owner

@sadnub commented on GitHub (Oct 11, 2021):

Yeah might have to use another field. I'm not sure how else to do it. As it stands, it will try and send the args as they are to the agent and the variable replacement would stop working

<!-- gh-comment-id:940436667 --> @sadnub commented on GitHub (Oct 11, 2021): Yeah might have to use another field. I'm not sure how else to do it. As it stands, it will try and send the args as they are to the agent and the variable replacement would stop working
Author
Owner

@silversword411 commented on GitHub (Oct 11, 2021):

As it stands, it will try and send the args as they are to the agent and the variable replacement would stop working

As it stands you just type new parameters...and then delete all the pre-filled ones ;) It makes for lots more clicking/deleting but it shows you the format of what you need to do.

If you do build a new part for the script GUI's, it'd be nice to have some color categories that can be applied to that somehow so you know required/optional/multiple options differentiation.

<!-- gh-comment-id:940445240 --> @silversword411 commented on GitHub (Oct 11, 2021): > As it stands, it will try and send the args as they are to the agent and the variable replacement would stop working As it stands you just type new parameters...and then delete all the pre-filled ones ;) It makes for lots more clicking/deleting but it shows you the format of what you need to do. If you do build a new part for the script GUI's, it'd be nice to have some color categories that can be applied to that somehow so you know required/optional/multiple options differentiation.
Author
Owner

@sadnub commented on GitHub (Oct 11, 2021):

I'm thinking for a script that has only optional parameters, it would require the box to be cleared in order to run properly. I think that anything that is copied into the args field should be a valid set of args since the args field in the community.json was intended to be for default args. It works really well scripts like ScreenConnect install because it needs certain args to run correctly and they don't change.

There definitely should be an indication of what is allowed though in the run script modal. Actually displaying the expected and optional args is really useful.

<!-- gh-comment-id:940480556 --> @sadnub commented on GitHub (Oct 11, 2021): I'm thinking for a script that has only optional parameters, it would require the box to be cleared in order to run properly. I think that anything that is copied into the args field should be a valid set of args since the args field in the community.json was intended to be for default args. It works really well scripts like ScreenConnect install because it needs certain args to run correctly and they don't change. There definitely should be an indication of what is allowed though in the run script modal. Actually displaying the expected and optional args is really useful.
Author
Owner

@silversword411 commented on GitHub (Oct 11, 2021):

I'll reverse out my parameters and await something from you on guidance/a course.

<!-- gh-comment-id:940500621 --> @silversword411 commented on GitHub (Oct 11, 2021): I'll reverse out my parameters and await something from you on guidance/a course.
Author
Owner

@sadnub commented on GitHub (Oct 11, 2021):

Can never remember what the command parameters are for scripts.

Option 1 Add a new item in the .json tip and show under script name selection. In this example I tried to emulate powershell notation (successfully=unsure) Maybe call it "syntax"? Eg

,
  {
    "guid": "6c78eb04-57ae-43b0-98ed-cbd3ef9e2f80",
    "filename": "Win_Chocolatey_Manage_Apps_Bulk.ps1",
    "submittedBy": "https://github.com/silversword411",
    "name": "Chocolatey - Install, Uninstall and Upgrade Software",
    "description": "This script installs, uninstalls and updates software using Chocolatey with logic to slow tasks to minimize hitting community limits. Mode install/uninstall/upgrade Hosts x",
    "syntax": "[[Mode] {install,uninstall,upgrade}] [[Hosts] <string>]"
    "shell": "powershell",
    "category": "TRMM (Win):3rd Party Software>Chocolatey",
    "default_timeout": "600"
  }

Option 2 Display the description I can work on a standardized format for parameters. Support for new line (with /n?) a bonus.

2021-09-10_074601 - trmm script descriptions1

2021-09-10_074601 - trmm script descriptions2

What you did here will work. Creating another key for the command usage.

I just need to then created a db field for the usage data and display it in the UI

<!-- gh-comment-id:940501906 --> @sadnub commented on GitHub (Oct 11, 2021): > Can never remember what the command parameters are for scripts. > > Option 1 Add a new item in the .json tip and show under script name selection. In this example I tried to emulate powershell notation (successfully=unsure) Maybe call it "syntax"? Eg > > ``` > , > { > "guid": "6c78eb04-57ae-43b0-98ed-cbd3ef9e2f80", > "filename": "Win_Chocolatey_Manage_Apps_Bulk.ps1", > "submittedBy": "https://github.com/silversword411", > "name": "Chocolatey - Install, Uninstall and Upgrade Software", > "description": "This script installs, uninstalls and updates software using Chocolatey with logic to slow tasks to minimize hitting community limits. Mode install/uninstall/upgrade Hosts x", > "syntax": "[[Mode] {install,uninstall,upgrade}] [[Hosts] <string>]" > "shell": "powershell", > "category": "TRMM (Win):3rd Party Software>Chocolatey", > "default_timeout": "600" > } > ``` > > Option 2 Display the description I can work on a standardized format for parameters. Support for new line (with /n?) a bonus. > > ![2021-09-10_074601 - trmm script descriptions1](https://user-images.githubusercontent.com/13395348/132850282-9bc50a3e-404b-4590-8367-4b461e918882.png) > > ![2021-09-10_074601 - trmm script descriptions2](https://user-images.githubusercontent.com/13395348/132850295-fc303977-b626-4c5b-9faa-70873d486e5c.png) What you did here will work. Creating another key for the command usage. I just need to then created a db field for the usage data and display it in the UI
Author
Owner

@silversword411 commented on GitHub (Oct 11, 2021):

Sounds good.

Can you have the field parse, and colorize based on structure?

<!-- gh-comment-id:940503785 --> @silversword411 commented on GitHub (Oct 11, 2021): Sounds good. Can you have the field parse, and colorize based on structure?
Author
Owner

@sadnub commented on GitHub (Oct 11, 2021):

Yeah should be able to work that out too

<!-- gh-comment-id:940513642 --> @sadnub commented on GitHub (Oct 11, 2021): Yeah should be able to work that out too
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tacticalrmm#446
No description provided.