If you are about to launch a lengthy automation script, why not turn off the display right away instead of waiting for the screen saver timeout to kick in?
Here is a simple function that turns off your display immediately. Just move the mouse or press a key to turn it back on:
$code = @"
public class API
public static extern
int SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
$t = Add-Type -TypeDefinition $code -PassThru
$t::SendMessage(0xffff, 0x0112, 0xf170, 2)
ReTweet this Tip!
PoSH remoting is there for remote code execution on remote computers. Yet, for much of stuff like this, you must be an admin locally and remotely to do this sort of thing and the execution policy must be set to allow it, or you have to use other options for the code to execute. This is just as true for the one liner I show in my other comment.
OK, from a pure risk management perspective. Why just blank the display and leaving the computer logged on potentially running code using a highly privilege account that someone can just walk up and well, you know. Why not lock the system instead with this native Windows OS one-liner in your script.
Of course, one could wrap that in a function as well.
Great! How can I run it remotely?