I am having trouble restarting a service with APMServiceControl.exe with a bit of a complicated setup. I made a SAM template with a PowerShell Component monitor querying the Windows Network Category (Public, Private, Domain Authenticated). This is working fine. The desired remediation for when the Network category is not "Domain Authenticated" is to restart the Network Location Awareness Service so I added a Windows Service Monitor to the SAM template for that service. So now I need a Component ID for the service monitor component (usually "Up") when the other PowerShell monitor is "down" that I can provide to APMServiceControl.exe.
I was able to isolate the needed component ID with a SWQL variable.

The problem is when the action triggers successfully the log reads:
[1] WARN APMServiceControl.ControlServiceParams - Unable to parse component Id as an integer (${N=SWQL;M=SELECT).
My path to external programs is:
C:\Program Files\Solarwinds\Orion\APMServiceControl.exe ${N=SWQL;M=SELECT ID FROM [dbo].[APM_Component] WHERE Name = 'Windows Service Monitor - NlaSvc' AND ApplicationID = ${N=SwisEntity;M=Application.ApplicationID}} -c=RESTART
The SWQL Variable is contained in the line above and works fine in the Database Manager when I hard code the ApplicationID. If I hard code the ID APMServiceControl.exe 81805 -c=RESTART it works fine, just not with the query for the ComponentID. Is there something wrong with what I'm doing or a better way?
I was originally calling a PowerShell command as remediation but when the server is in the state I'm monitoring, WinRM is blocked by the Windows Firewall so it doesn't work. APMServiceControl is a great workaround for this if someone can help me sort out what is wrong with my ComponentID variable query.