<?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[Agent Policy: How do I get "$_" as literal into an external parameter ?]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm currently trying to get an external parameter on a Windows host working.<br />
NetXMS Version as well as the Agent version is 2.1.</p>
<p dir="auto">The Agent Policy</p>
<pre><code>ExternalParameter=Ext.grep_count(*):powershell.exe -command "Select-String -Path \"$1\" -Pattern \"$2\" | Measure-Object | Foreach-Object { echo $_.Count }"
</code></pre>
<p dir="auto">gets called, but reports "_.Count" as value of the Parameter.</p>
<p dir="auto">I assume that the "$_.Count" gets replaced by NetXMS somewhere by "_.Count", so the echo returns this string only.</p>
<p dir="auto">Is there a way to escape "$" in the Agent Policy ? I already tried to "\$_.Count" (returning \.Count as value).</p>
<p dir="auto">Kind regards,</p>
<p dir="auto">Thomas<br />
PS: as the External parameter is called, I think you can cancel <a href="https://track.radensolutions.com/issue/NX-1233" rel="nofollow ugc">https://track.radensolutions.com/issue/NX-1233</a></p>
]]></description><link>https://forum.netxms.org/topic/5256/agent-policy-how-do-i-get-_-as-literal-into-an-external-parameter</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 16:07:10 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/5256.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Sep 2017 10:44:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Agent Policy: How do I get "$_" as literal into an external parameter ? on Fri, 13 Oct 2017 05:13:46 GMT]]></title><description><![CDATA[<p dir="auto">Hi Thomas,</p>
<p dir="auto">$ marks a parameter passed by NetXMS, hence $_ will not work for you.<br />
For a literal $, write $$, so your line would look as follows:</p>
<pre><code>ExternalParameter=Ext.grep_count(*):powershell.exe -command "Select-String -Path \"$1\" -Pattern \"$2\" | Measure-Object | Foreach-Object { echo $$_.Count }"
</code></pre>
<p dir="auto">Cheers</p>
]]></description><link>https://forum.netxms.org/post/23192</link><guid isPermaLink="true">https://forum.netxms.org/post/23192</guid><dc:creator><![CDATA[Tursiops]]></dc:creator><pubDate>Fri, 13 Oct 2017 05:13:46 GMT</pubDate></item></channel></rss>