<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[PowerShell Variables in ExternalParameters don't work?]]></title><description><![CDATA[<p dir="auto">Making literal $ doesn't work for ExternalParameters in 3.6-300 it seems as per <a href="https://www.netxms.org/forum/general-support/agent-policy-how-do-i-get-'$_'-as-literal-into-an-external-parameter/" rel="nofollow ugc">this other thread</a>?</p>
<p dir="auto">Unless there is some other way to run PowerShell commands?</p>
<p dir="auto"><strong>nxagentd.conf</strong> portion:</p>
<pre><code>ExternalParameter=Get-ScheduledTask(*):powershell.exe -NoProfile -Command "$$Parameter = \"$2\"; Write-Host (Get-ScheduledTask -TaskName \"$1\").$$Parameter"
</code></pre>
<p dir="auto"><strong>nxagentd.log</strong> portion:</p>
<pre><code>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
</code></pre>
]]></description><link>https://forum.netxms.org/topic/6818/powershell-variables-in-externalparameters-don-t-work</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 08:25:09 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/6818.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 16 Dec 2020 07:46:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to PowerShell Variables in ExternalParameters don't work? on Wed, 16 Dec 2020 23:34:32 GMT]]></title><description><![CDATA[<p dir="auto">I would restart the agent just to make sure, but you probably already did that.</p>
<p dir="auto">There could be a few ways for the agent to read another config then the default one</p>
<ul>
<li>running it with -c &lt;config_file_name&gt;</li>
<li>running it with -M &lt;server_ip&gt; - it would get config file from server</li>
<li>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).</li>
</ul>
]]></description><link>https://forum.netxms.org/post/29083</link><guid isPermaLink="true">https://forum.netxms.org/post/29083</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Wed, 16 Dec 2020 23:34:32 GMT</pubDate></item><item><title><![CDATA[Reply to PowerShell Variables in ExternalParameters don't work? on Wed, 16 Dec 2020 17:12:28 GMT]]></title><description><![CDATA[<p dir="auto">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.</p>
]]></description><link>https://forum.netxms.org/post/29081</link><guid isPermaLink="true">https://forum.netxms.org/post/29081</guid><dc:creator><![CDATA[Staj]]></dc:creator><pubDate>Wed, 16 Dec 2020 17:12:28 GMT</pubDate></item><item><title><![CDATA[Reply to PowerShell Variables in ExternalParameters don't work? on Wed, 16 Dec 2020 11:49:48 GMT]]></title><description><![CDATA[<p dir="auto">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?<br />
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).</p>
<p dir="auto">I've tried with agent 3.6.300. Here's my config:</p>
<pre><code>ExternalParameterShellExec=Get-ScheduledTask(*):powershell.exe -NoProfile -Command "$$Parameter = \"$2\"; Write-Host (Get-ScheduledTask -TaskName \"$1\").$$Parameter"
</code></pre>
<p dir="auto">And that's the log:</p>
<pre><code>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
</code></pre>
]]></description><link>https://forum.netxms.org/post/29068</link><guid isPermaLink="true">https://forum.netxms.org/post/29068</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Wed, 16 Dec 2020 11:49:48 GMT</pubDate></item></channel></rss>