I am wondering if it is possible to run a PowerShell script from within an Office Script. My goal is to call the Office Script from PowerAutomate, then have the Office Script kick off a PowerShell process that performs some other automated tasks. This is the code I have so far and I am getting the error "See line 3, column 5:Office Scripts cannot infer the data type of this variable. Please declare a type for the variable."
function main(workbook: ExcelScript.Workbook)
{
var spawn = require('child_process').spawn;
var child = spawn('powershell.exe', ['C:/Users/utrl/PythonWatcher.ps1']);
child.stdout.on('data', function(data){
console.log('DATA:', data.toString());
});
child.stdout.on('close', function(data){
console.log('psscript closed');
});
}
Does anyone know what I am doing wrong here, or an easier way to accomplish what I am trying to do in Office Scripts? For further context, I want the PS to kick off as a result of the PowerAutomate flow. The company I work at does not have PowerAutomate desktop (which I know has way more flexibility to kick off code). I also do not want to use task scheduler to kick off the PS as my company does not allow task scheduler to run when users are not logged in, and I need this process to run regardless of if a user is logged in. So I am working with some constraints here.
Any help or guidance is greatly appreciated!