I have a small node.js app from which I wish to send array of objects to a function in powershell script and manipulate it there. I'm using node-powershell library for this purpose. But the problem is I'm not able to catch the Array of objects as parameter in powershell function, it's giving unexpected error.
app.get('/preview-rule', async (req, res) => {
let ps = new Shell({
executionPolicy: 'Bypass',
noProfile: true
});
let rules = [{
path: "amer/arbue/legacy",
ldapFilter: "(&(sAMAccount=*k))"
}, {
path: "",
ldapFilter: "(&(l=u*))"
}];
ps.addCommand('. ./Scripts/PSScript1.ps1')
ps.addCommand('PreviewRule')
ps.addParameter({ rules: JSON.stringify(rules) })
ps.invoke()
.then(output => {
console.log(output);
res.status(200).send('success!');
})
.catch(err => {
console.log(err);
ps.dispose();
});
});