Jump to content

Scheduled Task Not Starting on Windows Server 2022 Until User Logs In


Recommended Posts

Guest /u/Hairy-Pension3651
Posted

### Question:

 

I’m experiencing an issue with a PowerShell script that creates and starts a scheduled task. This script works without any issues on **Windows Server 2019**. However, on **Windows Server 2022**, the task is created successfully and shows up with the status `Ready`, but it does not start as scheduled until a user manually logs in to the server. Below code runs a powershell remoting session.

 

Here’s the PowerShell script I'm using:

 

```powershell

 

$action = New-ScheduledTaskAction -Execute $ExeName -Argument $Arguments

 

$settings = New-ScheduledTaskSettingsSet

 

$adminGroup = (Get-LocalGroup -SID 'S-1-5-32-544').Name

 

$principal = New-ScheduledTaskPrincipal -GroupID $adminGroup -RunLevel Highest

 

$task = New-ScheduledTask -Action $action -Settings $settings -Principal $principal

 

Register-ScheduledTask -TaskName $TaskName -InputObject $task -Force | Out-Null

 

Start-ScheduledTask -TaskName $TaskName -AsJob | Out-Null

 

```

 

- `$ExeName` and `$Arguments` are set to the correct executable and arguments.

 

- The task is configured to run with **highest privileges** under the **Administrators group**.

 

The task appears in **Task Scheduler** with the status `Ready`, but it doesn’t trigger until a user logs in, which defeats the purpose of automation.

 

### What I've Tried:

 

- Verified that the task works as expected on Windows Server 2019 with the same settings.

 

### Additional Information:

 

- I am unable to use any account other than `Administrators` since the executable requires it.

 

- The server has all the latest updates installed.

 

- Running PowerShell 5.1 for this script.

 

Is there any difference in task scheduling behavior between Windows Server 2019 and 2022 when tasks are created and started from a PowerShell remoting session? Any help or suggestions would be greatly appreciated.

 

submitted by /u/Hairy-Pension3651

[link] [comments]

 

Continue reading...

  • Replies 0
  • Created
  • Last Reply

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...