Hi, I would like to run a Powershell script while my PC sleeps (actually the script checks for the battery level and whether the PC is plugged or not, if battery is low and PC not plugged, it will stop the PC to save the remaining battery).
I have written the corresponding Powershell script. I can set up a schedule task that will launch the script. It works as long as I tick the “Run only when user is logged on” box. But in this case, it won’t launch when my PC is at sleep.
When I tick the “Run whether user is logged on or not”, the task will start, but won’t run Powershell. From looking up on different sites, my understanding is that when this box is ticked, tasks will not run interactively, and that may prevent Powershell from launching.
So my question is: is there a way to launch Powershell in the background.
Or can you think of a different way of doing this ?
Thanks a lot in adavance for your help