Task Scheduler trigger "on remote connection to" not firing on new RDP session

Fossie 21 Reputation points
2020-08-06T05:47:03.12+00:00

I'm trying to use Task Scheduler to send an email every time someone logs on via remote desktop. Now there's a specific trigger in Task Scheduler called "on connection to user session" with settings that can be set to "Connection from remote computer". I use this to perform the action of running a PS script that sends the email. This works.

However, the trigger only fires when someone reconnects to a previously disconnected RDP session. Performing a fresh logon via RDP does not trigger the task. What's worse, I would swear that this was not a problem yesterday, before I pat myself on the back on a job well done and shut down the server before going to bed. I'm sure the task fired on both fresh logons as well as reconnects, and tested this multiple times.

So I guess I have two questions; what could have caused the task to change it's behavior from a reboot, and how can I get it working again? I tried creating a new identical task, but that didn't help. Are there other options/solutions I should pursue to achieve my goal?

I'm doing this on a Win 10 Pro system.

Best regards

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,213 questions
Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,598 questions
0 comments No comments
{count} votes

Accepted answer
  1. 2020-08-07T08:22:49.157+00:00

    hi,

    You can use Register-ScheduledTask to have a try. You can try scheduling a task on your local machine for whenever a user login session starts. Here's the script to do that:
    $action = New-ScheduledTaskAction -Execute "Cmd"
    $trigger = New-ScheduledTaskTrigger -AtLogon
    Register-ScheduledTask StartAtUserLogin -Action $action -Trigger $trigger -Description "Schedule Task at User Login" -RunLevel Highest

    You can specify your required action in the $action parameter. Once this code is working fine for your local machine, you can just put this script inside a Scriptblock and call this script using Invoke-Command cmdlet:
    Invoke-Command -ComputerName $myserver -Credential $cred -Scriptblock { #place above script here }

    --please don't forget to Accept as answer if the reply is helpful--


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.