Table of Contents

Intune: Uninstalling an Old Management Engine

This article focuses on removing the Silverlight-linked Intune Management Engine from an endpoint machine running Windows 10.

How-To

Before any scripts can be run, you will first need to identify the Intune service's GUID.

1. On the target machine, press Win+R, type regedit into the Run… dialog box, then press Enter.

2. Navigate to HKLM\SOFTWARE\Microsoft\OnlineManagement and you will find a key with the GUID of the Intune service.

3. Next, open an elevated command prompt window and cd to:

C:\Program Files\Microsoft\OnlineManagement\Common


4. Run the following executable, along with its parameters, in the command prompt window:

ProvisioningUtil.exe /UninstallClient /ServiceId {GUID} /TaskName “tempTask” /SubEventId 16

Note: Substitute {GUID} with the Intune service's GUID obtained in Step 2.

Automatic Uninstall Script

Paste the below script into an elevated PowerShell console to automatically retrieve the Intune service GUID and substitute it into the uninstall script. This will completely uninstall the management agent upon successful run.

function Get-ServiceId {
    #Set the registry path containing the service ID
    $RegistryPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OnlineManagement"
    try {
        #Get all the names of the items in the registry location
        $RegistryItems = (Get-ChildItem -Path Registry::$RegistryPath -ErrorAction Stop).Name
        #Loop through all the results
        foreach ($RegistryItem in $RegistryItems) {
            #Find the result that starts with the registry location followed by the first sign of a GUID
            if ($RegistryItem.StartsWith("$RegistryPath\{")) {
                #Replace the registry location with nothing to get the GUID
                $ServiceId = $RegistryItem.Replace("$RegistryPath\","")
                break
            }
        }
        return $ServiceId
    }
    catch {
        Write-Output "The Microsoft Intune client is not installed"
    }
}

function Start-Uninstall {
    param (
    [parameter(Mandatory=$true)]$ServiceId
    )
    try {
        #Set the ProvisioningUtil location and parameters
        $ProvisioningUtilPath = "C:\Program Files\Microsoft\OnlineManagement\Common"
        $ProvisioningUtilExecutable = "ProvisioningUtil.exe"
        $ProvisioningUtilArguments = "/UninstallClient /ServiceId $ServiceId /TaskName 'tempTask' /SubEventId 16"
        #Trigger the uninstall of the Microsoft Intune client
        Start-Process -FilePath "$($ProvisioningUtilPath)\$($ProvisioningUtilExecutable)" -ArgumentList $ProvisioningUtilArguments -Wait -PassThru
    }
    catch {
        Write-Output "Failed to trigger the uninstall of the Microsoft Intune client"
    }
}
echo "Running"
Start-Uninstall (Get-ServiceId)

Self-Contained Automatic Uninstall Script Package

The above steps have been compiled into a self-contained script package, which can be downloaded here. Extract all files from the zip file into a single location, then run the .bat file as administrator.

References