How can I configure Windows 11 pro to send an email immediately prior to shutdown?
I've written a simple powershell script to send an email (this works fine) but I'm having trouble persuading the task scheduler to run it successfully.
Task details.....
- Basic Task, 'on an event'
- log is set to 'system'
- Source is 'user32'
- Event Id 1074
- Run with highest privileges
Running the schedule manually seems to work fine, the script runs and the email is sent.
If I select 'shutdown and reboot' the system shuts down and reboots as expected. After the reboot the event viewer indicates an event of ID 1074 has occurred.
The history for the task also indicates that the task has run successfully, it's triggered, created, started and completed without problem (according to the task schedule history). However, the email never get's sent, and the log file (for the powershell script) doesn't exist which suggests it was never actually runs, despite what the task history may claim.
Why isn't the script actually being called, and how can I fix it?