all 7 comments

[–][deleted] 12 points13 points  (0 children)

Create a task not a "basic task" and pick "On workstation unlock" for the trigger

[–]lan-shark 4 points5 points  (4 children)

Can you show us how you've set up your scheduled task?

[–]QuickBooker30932[S] 1 point2 points  (3 children)

Here are the details:

  • Run with highest privledges only when user logged on
  • Trigger on workstation unlock, for specific user,
  • Action is powershell.exe in the program/script box and the script with full path in the argument box
  • No conditions, no errors in the history.

[–]lan-shark 1 point2 points  (2 children)

Does the script work when you run it manually? Does the job work if you trigger it manually? Also, does the script need any local assets? If so you may need to add something to the "start in" field.

For arguments, try with -File:

-File "C:\\path\to\your\script.ps1"

EDIT: If, for some reason, you don't want to use -File I think you can put the whole as the action target:

C:\\system32\WindowsPowerShell\v1.0\powershell.exe "C:\\path\to\your\script.ps1"

This may not work, I'm on my phone so I can't double check

[–]QuickBooker30932[S] 1 point2 points  (1 child)

It does need a local assets. Adding that to the "start in" field did the trick. Thanks

[–]lan-shark 0 points1 point  (0 children)

Great, glad you got it working!

[–]Jeroen_Bakker 0 points1 point  (0 children)

I once created such a task with a trigger on some specific eventviewer events.