Powershell help

Started by Spheron, May 20, 2026, 12:52:58 PM

Previous topic - Next topic

Spheron


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


Alex Kirhenshtein

Try escaping $ in the query