Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. PowerShell Variables in ExternalParameters don't work?

PowerShell Variables in ExternalParameters don't work?

Scheduled Pinned Locked Moved Support
4 Posts 2 Posters 30.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    S
    Staj
    wrote on last edited by
    #1

    Making literal $ doesn't work for ExternalParameters in 3.6-300 it seems as per this other thread?

    Unless there is some other way to run PowerShell commands?

    nxagentd.conf portion:

    ExternalParameter=Get-ScheduledTask(*):powershell.exe -NoProfile -Command "$$Parameter = \"$2\"; Write-Host (Get-ScheduledTask -TaskName \"$1\").$$Parameter"
    

    nxagentd.log portion:

    2020.12.16 18:38:36.287 *D* [comm.cs.5          ] Received message CMD_GET_PARAMETER (699)
    2020.12.16 18:38:36.287 *D* [comm.cs.5          ] Requesting parameter "Get-ScheduledTask("Test Task", "State")"
    2020.12.16 18:38:36.287 *D* [comm.cs.5          ] H_ExternalParameter called for "Get-ScheduledTask("Test Task", "State")" "Spowershell -NoProfile -Command "$Parameter = \"$2\"; Write-Host (Get-ScheduledTask -TaskName \"$1\").$Parameter""
    2020.12.16 18:38:36.287 *D* [exec               ] RunExternal called for "Get-ScheduledTask("Test Task", "State")" "Spowershell -NoProfile -Command "$Parameter = \"$2\"; Write-Host (Get-ScheduledTask -TaskName \"$1\").$Parameter""
    2020.12.16 18:38:36.287 *D* [exec               ] RunExternal: command line is "powershell -NoProfile -Command "Parameter = \"State\"; Write-Host (Get-ScheduledTask -TaskName \"Test Task\").Parameter""
    2020.12.16 18:38:36.287 *D* [exec               ] RunExternal (shell exec): worker thread created
    
    1 Reply Last reply
    0
    • F
      F
      Filipp Sudanov
      wrote on last edited by
      #2

      Are you sure that nxagentd.conf portion is exactly the same that the agent is running with? Was agent restarted to work with actual config?
      For me "RunExternal (shell exec): worker thread created" only appears when ExternalParameterShellExec is used (by the way this soon gonna be reworked and all actions and external parameters will be lauched as ShellExec).

      I've tried with agent 3.6.300. Here's my config:

      ExternalParameterShellExec=Get-ScheduledTask(*):powershell.exe -NoProfile -Command "$$Parameter = \"$2\"; Write-Host (Get-ScheduledTask -TaskName \"$1\").$$Parameter"
      

      And that's the log:

      2020.12.16 03:41:40.720 *D* [comm.cs.50         ] Requesting parameter "Get-ScheduledTask("Test Task", "State")"
      2020.12.16 03:41:40.720 *D* [comm.cs.50         ] H_ExternalParameter called for "Get-ScheduledTask("Test Task", "State")" "Spowershell.exe -NoProfile -Command "$$Parameter = \"$2\"; Write-Host (Get-ScheduledTask -TaskName \"$1\").$$Parameter""
      2020.12.16 03:41:40.720 *D* [exec               ] RunExternal called for "Get-ScheduledTask("Test Task", "State")" "Spowershell.exe -NoProfile -Command "$$Parameter = \"$2\"; Write-Host (Get-ScheduledTask -TaskName \"$1\").$$Parameter""
      2020.12.16 03:41:40.720 *D* [exec               ] RunExternal: command line is "powershell.exe -NoProfile -Command "$Parameter = \"State\"; Write-Host (Get-ScheduledTask -TaskName \"Test Task\").$Parameter""
      2020.12.16 03:41:40.720 *D* [exec               ] RunExternal (shell exec): worker thread created
      
      1 Reply Last reply
      0
      • S
        S
        Staj
        wrote on last edited by
        #3

        I thought the same thing but the nxagentd.conf on disk and the Agent Configuration that matches for the node in NetXMS are all identical, as written. I couldn't work it out either.

        1 Reply Last reply
        0
        • F
          F
          Filipp Sudanov
          wrote on last edited by
          #4

          I would restart the agent just to make sure, but you probably already did that.

          There could be a few ways for the agent to read another config then the default one

          • running it with -c <config_file_name>
          • running it with -M <server_ip> - it would get config file from server
          • configuration policies that add up to the config - they reside in system32/config/systemprofile/appdata/local/nxagentd/config_ap/  (or other user home folder, if agent is started under other user, not system one).
          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          Powered by NodeBB Contributors
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups