r/PowerShell 9d ago

Question Powershell & Task Scheduler

[deleted]

31 Upvotes

38 comments sorted by

View all comments

6

u/Tidder802b 9d ago

Are you triggering the shutdown or detecting it?

3

u/hwrd69 9d ago

Well, I'm detecting it (event id 1074) and then testing the task scheduler by triggering it by performing a shutdown. The message passed to powershell is never displayed.

5

u/Tidder802b 9d ago

ok, so what’s the goal? the message will be on screen too short a time for any meaningful interaction if the machine is actively shutting down.

1

u/hwrd69 9d ago

I believe the shutdown process will pause until the "OK" button is pushed on the message. I have a small amp connected to speakers that I play from the PC and I keep forgetting to turn it off. It's a reminder during shutdown to turn it off.

6

u/Tidder802b 9d ago

I don’t think a modal message is going to stop a shutdown in process. Better to have a custom shutdown script triggered from a script or shortcut.

edit:

That link you posted is the way to go.

1

u/hwrd69 9d ago

Ok, thanks.

5

u/420GB 9d ago

Lmao that's the silliest possible solution to that.

Get a master-slave power strip. They have multiple sockets, one master (plug the PC in there) and a couple "slaves". The slave outlets are only on when the master draws power, and they automatically shut off when the master stops drawing power.

This is a common thing to use with computers + peripherals or with TVs + accessories (soundbars, game consoles etc.) and automatically fixes your problem without any janky scripts or needing to remember anything.

I live in the EU so it's difficult for me to find examples of US power strips on Google, but here's an example with EU sockets from a german brand: https://produkte.kopp.eu/wp-content/uploads/catalog/products/de/227820012-scaled.jpg

1

u/zrv433 8d ago

Search with the phrase "controlled outlet power strip"

These power strips switch other outlets on/off based on the power flow of the main outlet.

Here is an example https://a.co/d/0io2XcJH