For the complete documentation index, see llms.txt. This page is also available as Markdown.

Running a task sequence from Intune

As described in the previous section, you can run a task sequence from an existing OS. You can also initiate a task sequence from Intune, allowing it to perform tasks such as installing applications in a specified order.

Use a PowerShell script to initiate the task sequence. For example:

# If we are running as a 32-bit process on an x64 system, re-launch as a 64-bit process
if ("$env:PROCESSOR_ARCHITEW6432" -ne "ARM64") {
	if (Test-Path "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe") {
		& "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy bypass -NoProfile -File "$PSCommandPath"
		Exit $lastexitcode
	}
}

# Run the specified task sequence
$DeployRBootstrap = @{ ProgressTimeout = "1" }
iex (irm "https://our-server-name.com:7281/v1/Service/Bootstrap?tsid=5d1e3201-36cb-433c-88b4-71c031f653fa:1")

# Creating tag file so that Intune can see that it is installed
Mkdir "$($env:ProgramData)\2Pint Software" -Force | Out-Null
Set-Content -Path "$($env:ProgramData)\2Pint Software\RunTS.ps1.tag" -Value "Installed"

Update the script with your DeployR server URL, task sequence ID (GUID), and version.

To run this script from Intune, package it as a Win32 app and specify the following:

  • Installation command line: powershell.exe -noprofile -executionpolicy bypass -file RunTS.ps1

  • Detection rule: File "%ProgramData%\2Pint Software\RunTS.ps1.tag" exists

You can then assign the app to the appropriate device group. For Windows Autopilot (v1), include this app in the list of blocking apps in your enrollment status page settings. For Windows Autopilot device preparation (v2), the same can also be done, or alternatively the script can be added to Intune as a platform script and included in the list of blocking scripts in the device preparation profile.

Note that the task sequence being executed should not initiate a reboot.

Last updated