Software Programs are not removed from Inv_AddRemoveProgram table even though they were uninstalled
search cancel

Software Programs are not removed from Inv_AddRemoveProgram table even though they were uninstalled

book

Article ID: 278696

calendar_today

Updated On:

Products

Asset Management Suite Client Management Suite IT Management Suite

Issue/Introduction

Programs are not removed from the Inv_AddRemoveProgram table even though they were uninstalled

How long does it take for applications to disappear from the ```Inv_AddRemoveProgram``` table in the CMDB after a program has been removed?

I have run a Software Inventory task and have also rebooted the system, but my query still shows an application is installed. I have confirmed the application is no longer under add/remove programs.

I expect that it should almost immediately drop off this table.

The following is my SQL query / Report.  It joins the Inv_AddRemoveProgram table and also provides ranking if more than one software has the same name.  

with Computer as (

 select
  vc.Guid /* required for Altiris filters */
  ,vc.[Name] as Computername
  ,vc.IsManaged
  ,vc.[User]
  ,vsa.Owner
  ,vsa.Division
  ,vsa.[Asset Type] as AssetType
  ,vsa.[Status]
  ,vsa.Model
 from
  vComputer vc
 left join
  vSCCAsset vsa
 on vc.Guid = vsa._ResourceGuid
 where
  (
   [Asset Type] = 'Computer'
   OR [Asset Type] = 'Virtual Machine'
  )
  AND IsManaged = 1

),

Software as (

 select
  _ResourceGuid as guid
  ,DisplayName
  ,DisplayVersion
 from
  Inv_AddRemoveProgram
 where 
  displayname like '%MySoftware%' 

)


select
 c.Guid /* required for Altiris filters */
 ,Computername
 ,IsManaged
 ,[User]
 ,[Owner]
 ,Division
 ,AssetType
 ,[Status]
 ,Model
 ,DisplayName
 ,DisplayVersion
 ,VersionRank
from
 computer c
left join (
 select
  --provides ranking if more than one version is installed
  guid
  ,DisplayName
  ,DisplayVersion
  ,row_number() over (partition by [guid] order by DisplayVersion desc) as VersionRank
 from
  software
) as s
on c.Guid = s.guid
where
 --VersionRank = 1 --eliminates duplicates; shows highest version if there's more than one listed
 --AND
 DisplayName is not null
order by 
 ComputerName desc, VersionRank

Environment

ITMS 8.6 and 8.7

Cause

Inventory does not remove the Data from the Inv_AddRemoveProgram table immediately but it does set the InstallFlag to 0 when software is uninstalled.  To catch these changes the report should add an "InstallFlag = 1" statement in the Software section.

Resolution

Add the and InstallFlag = 1 as shown below in blue.

Software as (

 select
  _ResourceGuid as guid
  ,DisplayName
  ,DisplayVersion
 from
  Inv_AddRemoveProgram
 where 
  displayname like '%MySoftware%' 
and InstallFlag = 1
)