NetXMS Support Forum

English Support => General Support => Topic started by: Spheron on May 20, 2026, 12:52:58 PM

Title: Powershell help
Post by: Spheron on May 20, 2026, 12:52:58 PM

Hello @all,

i have following code in a template:


<config>
<core>
<ExternalMetric>WindowsADUserGroup.Count(*):powershell -NoProfile -NonInteractive -Command "Write-Host ((Get-ADGroupMember -Identity '$1' -Recursive | Where-Object { $_.objectClass -eq 'user' }).count)"</ExternalMetric>
</core>
</config>

If i run the code directly on a server, there are no errors..

If i run the script via NetXMS DC, i getting the error that "_.objectClass" is not found...

Where is my fault? I didn't get a solution for that... Many thanks for any help...

Greetings
Marco

Title: Re: Powershell help
Post by: Alex Kirhenshtein on May 20, 2026, 03:47:48 PM
Try escaping $ in the query