I need to run javascript code on an ninjaRMM managed device.
I know how to do it using a powershell script,I have problems doing it with a javascript.
When this script is added to the ninjaRMM library and then run on a device, I get errors: syntax error:const; console.log:console is undefined
The above errors are signed with “Microsoft Script Host v5.81 which does support “const” keyword and I still can’t figure out what is in the global namespace on that engine.
Googling has been hopeless: all I can find is info on accessing the Ninja API from a node server.
- Add simple hello world as new script in library in ninja console Administration=>Scripts:
const msg = “Hello World!!”;
console.log(msg);
- Open device in the console=>Run=>from library=>my script
- Script returns with “success”
- clicking more in the status box yields:
output:
Hello World!!