How to wipe old Software Inventory data if Software Invetory shows uninstalled Software.
Symptoms: If we install any software on a client run SW inventory it will be populated to the DB, uninstalling the software removes the entries from the DB as expected. However there are some historical information about SW which will not be removed if uninstalled on the client.
Solution:
1- Create a full DB backup. (just incase)
2- Run the following SQL query, which will wipe all the software inventory information for all your clients.
-- Begin of SQL query --
Declare @ID int
Declare @Name varchar (max)
Declare @GUID uniqueidentifier
create table #vcomp
(
[id] bigint identity (1,1) not null,
[Name] varchar (max),
[GUID] uniqueidentifier
)
insert into #vcomp (Name, GUID) (select name, guid from vComputer)
set @ID = '1'
set @GUID = (select GUID from #vcomp where ID = @ID)
while @GUID is not null
begin
set @GUID = (select GUID from #vcomp where ID = @ID)
set @Name = (select Name from #vcomp where ID = @ID)
exec dbo.[sp_Inv_Installed_File_Details_resource_delete] @GUID
exec dbo.[sp_Inv_InstalledSoftware_resource_delete] @GUID
exec dbo.[sp_Inv_AddRemoveProgram_resource_delete] @GUID
print @Name
Print @guid
set @ID = @ID + 1
end
drop table #vcomp
-- End of SQL query --
3- Run Software Inventory on all your clients to collect the updated set of installed software. If your Inventory tasks/policies run successfully, any uninstalled software on the client will be removed from the Software Inventory after next SW inventory runs.