Friday, September 19, 2025

Deploy a Scheduled Task in Intune


Unlike with GPOs / GPPs, Intune doesn't currently have a configuration profile option to deploy a scheduled task (ST).

The alternative is to deploy powershell scripts with a ST definition XML file in a Win32 App.

Manually create the ST.  Don't worry if you can't set it to SYSTEM and run while users logged off on the manually configured one.  This corrects itself during the export / import process.

Export the ST to a XML file.

Delete the manually created ST and import it back to check it imports correctly.

The import/install powershell looks like this.  Save it to a powershell file in the same folder as the XML

e.g. install.ps1

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$STImportFile = Join-Path $scriptDir "<STDefinition.xml>"

Register-ScheduledTask -TaskName "<TS Name>" -xml (Get-Content $STImportFile | Out-String)


The removal/uninstall powershell is simply this.  Save it to a powershell file in the same folder as the XML

e.g. uninstall.ps1

Unregister-ScheduledTask -TaskName "<TS Name>" -Confirm:$false


Create a detection powershell script for Intune detection.  Test it as with admin credentials.

$taskName = "<TS Name>"
$taskStatus = Get-ScheduledTask | ?{$_.TaskName -eq $taskName}
if ($taskStatus)
    {Exit 0}
    else
    {Exit 1}


That's the file set.  Use the IntuneWinAppUtil to create the uploadable Intune format.  For the -s switch just point to the Installation powershell script file.

Finally create an Intune Win32 app for deployment and upload the .intune file as the source.

Configure the install and uninstall commands as

powershell -executionpolicy bypasss -file .\install.ps1

powershell -executionpolicy bypasss -file .\uninstall.ps1

Upload the detection powershell script at the detection app setup stage.