I have a PowerShell script monitor component running in my NPM 12.0.1, SAM 6.3 environment and it is returning the 127.0.0.1 loopback IP address when providing it the ${IP} variable instead of the Node's polling IP Address. This is odd to me because as far as I knew the ${IP} variable is just a macro that queries the database and returns the Node's selected polling IP Address, but instead it seems to be asking the node itself for its IP address, at least when the Node is polled via Agent polling, and since the script is being run locally by the agent it is returning its loopback address for some weirdo reason. I've been able to workaround this by using the ${Node.Caption} variable, but that workaround may not work for many of my other script monitors.
I would like to know if this is a known issue or a weird bug or something?
The closest article I've found to my issue is this:
Agent Polling and PowerShell Scripts
The issue in that post seemed to be they were having problems with the ${Credential} variable working on agent polled nodes, which is funny because I had no problems with that once I reformatted my PowerShell script from this:
$creds = '${Credential}'
to this:
$creds = Get-Credential -Credential '${Credential}'
But when I put ${IP} in the Script Arguments box and then call it by doing this:
$ipAddress = $args[0]
It always returns 127.0.0.1 despite the node's IP_Address value in the NodesData table being it's real IP address, something like 10.0.0.150.
I'm using Local Execution mode, which means the script is being ran by the target node itself. I'm not sure if the issue persists in Remote Execution mode. I've also tried turning Impersonation on and off but it doesn't change the ${IP} returning as 127.0.0.1. I wouldn't expect the impersonation mode to change that anyways since that is more about how the credentials are handled than anything else. I also tried changing the App Monitor's preferred polling method to agentless but it didn't matter.