0

I have a PowerShell script which I am invoking to generate few pdf files the script is invoking node js script which is generating pdf files using react-pdf but issue is if one pdf generation failed it don't move on to next file on the list as I am getting a list of files from a remote endpoint, is there any way to kill the nodejs Invoke-Expression command process after one or two min and continue to next item

Anwar Javed
  • 325
  • 3
  • 11
  • As an aside: [`Invoke-Expression` (`iex`) should generally be avoided](https://stackoverflow.com/a/51252636/45375); definitely [don't use it to invoke an external program or PowerShell script / command](https://stackoverflow.com/a/57966347/45375). – mklement0 Feb 10 '23 at 18:27
  • Generally, you can use a [background job](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Jobs) to run a console application asynchronously in the background, which you can kill on demand from the foreground thread. – mklement0 Feb 10 '23 at 18:28
  • I tried to use Start-Job it starts but it don't do anything I am trying to execute a nodejs script – Anwar Javed Feb 11 '23 at 04:24

0 Answers0