This document clearly explains the process of uninstalling agent via Intune
Generate agent cleanup tool by following instructions in the document
NOTE : Copy the agentcleanuptoolclient.exe to the extracted folder.
To configure the app
Provide the install and uninstall command in the program tab
Configure Detection rule manually.