I want to call a powershell script with arguments from nodejs. I have tried the below but not working.
var spawn = require("child_process").spawn;
let comd = '"C:\\Cmdlets\\StartSessionPasswordShown.ps1 "arg1" "arg2" 35107 "arg4"';
child = spawn("powershell.exe", [comd]);
child.stdout.on("data", function (data) {
let res = data;
console.log("Powershell Data: " + res);
});
child.stderr.on("data", function (data) {
console.log("Powershell Errors: " + data);
});
child.on("exit", function () {
console.log("Powershell Script finished");
});
child.stdin.end();
And I am getting below error
Unexpected token 'arg1' in expression or statement. The string is missing the terminator: ".
Powershell Errors: + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken