Removing Software Installation Records from InTune Service Graph Connector

ctsmith
Mega Sage

We have multiple connectors for Discovery.  InTune is returning software installation records and populating the software installation CI table.  But... our data from InTune shows ALL installation records for a given application.  Take Chrome for example.  It shows the most current version installed as well as all previous versions for a given machine.  

Any thoughts on how to, say, just keep the most recent version of an install after a nightly discovery?  The SAM deduplication job is running... these are not duplicate records but different version records.

Table cleaner job that runs after InTune job filtered on InTune as the discovery source and then...? How do we get it to ditch everything but the most recent (or highest version number) record.

From a single machine in our CMDB.  All records of Chrome discovered in InTune:

find_real_file.png

Or is there a better way to head this off at the Robust Transformer source for the InTune Graph Connector?

4 REPLIES 4

ctsmith
Mega Sage

I posed another question about getting install date or any more details on the install that could be used but I parsed through the entire message that connector is returning and that information is not being returned.  Unfortunately it's very limited on the application installation information.  So... trying a BR that compares version numbers and removing only the most recent version.  Not ideal, but something...

(function executeRule(current, previous /*null when async*/ ) {
    var maj, min, maint, build, verse, theNum, installSys, getSoft, currentMaj, currentMin, currentMaint, currentBuild, currentVersion;
    currentVersion = current.version.split(".");
    currentMaj = parseInt(currentVersion[0]) || 0;
    currentMin = parseInt(currentVersion[1]) || 0;
    currentMaint = parseInt(currentVersion[2]) || 0;
    currentBuild = parseInt(currentVersion[3]) || 0;
    getSoft = new GlideRecord('cmdb_sam_sw_install');
    getSoft.addEncodedQuery('installed_on=' + current.installed_on + '^display_name=' + current.display_name);
    getSoft.query();
    while (getSoft.next()) {
        theNum = getSoft.version.split(".");
        maj = parseInt(theNum[0]) || 0;
        min = parseInt(theNum[1]) || 0;
        maint = parseInt(theNum[2]) || 0;
        build = parseInt(theNum[3]) || 0;
        if (currentMaj > maj) {
            getSoft.deleteRecord();
        } else if (currentMaj == maj && currentMin > min) {
            getSoft.deleteRecord();
        } else if (currentMaj == maj && currentMin == min && currentMaint > maint) {
            getSoft.deleteRecord();
        } else if (currentMaj == maj && currentMin == min && currentMaint == maint && currentBuild > build) {
            getSoft.deleteRecord();
        }
    }
})(current, previous);

I'm not sure if this is the ideal way to check against versions; it seems there may be better ways under Tokyo with updated ECMAScript version availability. 

A little update to this code.  This does remove all lower install versions for a given machine on the software installation table successfully.

It is an async business rule on the table:

 

(function executeRule(current, previous /*null when async*/ ) {
    var maj, min, maint, build, verse, theNum, installSys, getSoft, currentMaj, currentMin, currentMaint, currentBuild, currentVersion;
    currentVersion = current.normalized_version.split(".");
    currentMaj = parseInt(currentVersion[0]) || 0;
    currentMin = parseInt(currentVersion[1]) || 0;
    currentMaint = parseInt(currentVersion[2]) || 0;
    currentBuild = parseInt(currentVersion[3]) || 0;
    getSoft = new GlideRecord('cmdb_sam_sw_install');
    getSoft.addEncodedQuery('installed_on=' + current.installed_on + '^display_name=' + current.display_name);
    getSoft.query();
    while (getSoft.next()) {
        theNum = getSoft.normalized_version.split(".");
        maj = parseInt(theNum[0]) || 0;
        min = parseInt(theNum[1]) || 0;
        maint = parseInt(theNum[2]) || 0;
        build = parseInt(theNum[3]) || 0;
        if (currentMaj > maj) {
            getSoft.deleteRecord();
        } else if (currentMaj == maj && currentMin > min) {
            getSoft.deleteRecord();
        } else if (currentMaj == maj && currentMin == min && currentMaint > maint) {
            getSoft.deleteRecord();
        } else if (currentMaj == maj && currentMin == min && currentMaint == maint && currentBuild > build) {
            getSoft.deleteRecord();
        }
        //Updating table with new records with possible lower versions should delete itself:
        if (currentMaj < maj) {
            current.deleteRecord();
        } else if (currentMaj == maj && currentMin < min) {
            current.deleteRecord();
        } else if (currentMaj == maj && currentMin == min && currentMaint < maint) {
            current.deleteRecord();
        } else if (currentMaj == maj && currentMin == min && currentMaint == maint && currentBuild < build) {
            current.deleteRecord();
        }
    }
})(current, previous);

I agree it is pain when it comes intune integration, how do you delete uninstalled software and why not use sys_object_source table?

catia_alves
Tera Expert

Hi, experiencing same issue than you. Did you find a better way than this BR? Thank you