Rapid7 Insight agent is not an easy application to pack via SCCM 🙂
For detection rule, I have tried a few times, and here is the working one: (If you tried to use file detection rule, even if exists, sometimes it broke during self update process, and the service is not running, you got the wrong compliance report).
$Result = Get-Service ir_agent -ErrorAction SilentlyContinue | Select Status
$Result = $Result.Status
if ($Result -eq “Running”)
{Write-Host -Object “Installed”}
Else
{}
And for installation, we have to first remove any old existing entries, otherwise it won't install
REM Rapid7 Agent Install
REM by Rui Qiu
REM 6/3/2020
REM 2/23/2022
msiexec /x old.msi /l*v remove.log /quiet
REM reg query HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\ /f “Rapid7 Insight Agent” /s
reg delete “HKLM\SOFTWARE\Classes\Installer\Products\C4047A5E88D2C1C40839B16EE92CC042” /f
reg delete “HKLM\SOFTWARE\Rapid7″ /f
msiexec /i agentInstaller-x86_64.msi /l*v insight_agent_install_log.log /quiet CUSTOMTOKEN=us:05ef2af1-11bd-4d6e-b003-0b83979625a1 CUSTOMCONFIGPATH=”C:\Windows\Temp”