Forum Discussion

jmal's avatar
jmal
Copper Contributor
Jul 14, 2025

Immediate Restart from Intune

Hi everyone,

I'm looking for a way to remotely restart a Windows device enrolled in Intune—but with one key requirement: it needs to happen immediately, or as close to real-time as possible.

Here’s the situation:

  • All devices are Windows 10/11 and fully enrolled in Intune.
  • I have admin access and can use PowerShell, Graph API, or Power Automate.
  • I want to be able to trigger a restart from a script or flow, without requiring user interaction.
  • The goal is to restart a specific user’s computer on demand, ideally within seconds or a minute—not hours later when the device checks in.

I’ve tried:

  • Using the Intune Admin Center > Devices > Restart option — but it’s not immediate.
  • Triggering a sync first still not fast enough unless the user has company portal open on their machine
  • Exploring Power Automate and Graph API to call /restartNow or /wipe — but again, it depends on the device check-in.

Is there any way to:

  1. Force a device to check in immediately, or
  2. Push a restart command that executes instantly, assuming the device is online?

Bonus points if this can be done via a script or automated flow (e.g., triggered by a manager request or security event).

Any help, scripts, or creative workarounds would be hugely appreciated!

Thanks in advance!

5 Replies

  • jmal​ 

    Hy,

    you can not trigger a Restart, Reboot command directly via Platform Script or Remediation. 

    rahuljindal​ Kindly Reminder "

    I use this as a Platform Script in order to Rename Device in or after ESP or immediately after User Sign In.

    Bonus Function 😉

    Place the log if you want under "C:\ProgramData\Microsoft\IntuneManagementExtension\YourLogName" and adjust the time from the Task to your needs.

       # Define the log name (custom for this script)

    $LogName = "add log Name at your choice"

    function Write-Log {

        param (

            [string]$LogName,

            [string]$Message,

            [ValidateSet("Info", "Success", "Error")]

            [string]$LogType = "Info"

        )

        $LogDirectory = "add your Path here" # Define the path where logs will be stored

        # Create the log directory if it doesn't exist

        if (-not (Test-Path -Path $LogDirectory)) {

            New-Item -ItemType Directory -Path $LogDirectory -Force | Out-Null

        }

        # Create the log file name

        $LogFileName = "$LogName.log"

        $LogFilePath = Join-Path -Path $LogDirectory -ChildPath $LogFileName

        $Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"

        $FormattedMessage = "[$Timestamp] [$LogType] $Message"

        Add-Content -Path $LogFilePath -Value $FormattedMessage

        switch ($LogType) {

            "Info" { Write-Host $FormattedMessage -ForegroundColor White }

            "Success" { Write-Host $FormattedMessage -ForegroundColor Green }

            "Error" { Write-Host $FormattedMessage -ForegroundColor Red }

        }

    }

       # Check if the scheduled task already exists

    $taskName = "Name the task as you like"

    $taskExists = Get-ScheduledTask | Where-Object { $_.TaskName -eq $taskName }

    if (-not $taskExists) {

        try {

            Write-Log -LogName $LogName -Message "Creating scheduled task: $taskName" -LogType "Info"

            Write-Host "Creating scheduled task: $taskName" -ForegroundColor Yellow

        # Create the scheduled task

            $STaction = New-ScheduledTaskAction -Execute 'c:\windows\system32\shutdown.exe' -Argument '-r -t 0'

            $STtrigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(45) # Trigger Task 45 minutes from first run

            $STSet = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable

            $STuser = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest

            Register-ScheduledTask -TaskName $taskName -TaskPath "\" -Action $STaction -Settings $STSet -Trigger $STtrigger -Principal $STuser

            Write-Log -LogName $LogName -Message "Scheduled task $taskName created successfully." -LogType "Success"

        }

        catch {

            Write-Log -LogName $LogName -Message "Error creating scheduled task: $($_.Exception.Message)" -LogType "Error"

            Write-Host "Error creating scheduled task: $($_.Exception.Message)" -ForegroundColor Red

            exit 1

        }

    }

    else {

        Write-Log -LogName $LogName -Message "Scheduled task $taskName already exists. Skipping creation." -LogType "Info"

        Write-Host "Scheduled task $taskName already exists. Skipping creation." -ForegroundColor Yellow

    }

      # Wait for the task to execute

    Write-Log -LogName $LogName -Message "Waiting for the scheduled task to execute..." -LogType "Info"

    Write-Host "Waiting for the scheduled task to execute..." -ForegroundColor Yellow

    Start-Sleep -Seconds 20 # Wait for 20 seconds to ensure the task has time to execute

     

    Good luck!

     

    • rahuljindal's avatar
      rahuljindal
      Bronze Contributor

      Bogdan_Guinea​ why not? It is perfectly fine to use remediation for this as it supports scheduling of a task. Now should you use it, it will completely dependent on requirements. 

      • Bogdan_Guinea's avatar
        Bogdan_Guinea
        Iron Contributor

        I meant that no direct reboot, restart via DR or platform script works.

        Of course you can use a task for that, that's why I shared my PS to create a task.

        Good luck!

  • StuartPavy's avatar
    StuartPavy
    Copper Contributor

    Here’s a workaround concept I’ve been experimenting with that might help someone exploring remote restart strategies:

    Create a dedicated user account like RestartUser and configure a scheduled task that runs a restart script at logon. This task can be scoped specifically to that user so it only runs when someone connects via RDP using that profile. It gives you granular control without relying on Intune’s check-in cycle or push notifications.

    You can even add conditional logic to the script—such as checking for uptime > 72 hours—before initiating the restart. It’s not a production-grade solution, but it might be an interesting route to prototype if you have RDP access and want repeatable restart behavior tied to session events.

Resources