/build/static/layout/Breadcrumb_cap_w.png

Leveraging Custom Inventory Rules and Scripting in KACE

Problem:
An application we have in our environment had generated temp files that were causing conflicts.  We upgraded the application to a newer version the vendor promised would not do this.  Once we did that machines that once had the old version still had those old temp files.

Requested Action:
Now that the upgrade is done delete the temp files ASAP!

Technical Response:
Report what machines have these temp files and delete them.

Method:
Write a script that will dump the file names of these temp files to a text document that can be reported on AND deletes the files.  Create a report to see what machines had these temp files on it.

Step 1: Script
@echo off
cd /d c:\Documents and Settings\All Users\ProgFolder
echo spitting file list to a txt doc
dir /b *.tmp >C:\PG_tmp_list.txt
echo removing .tmp files from Documents and Settings\All Users\ProgFolder
cd /d c:\Documents and Settings\All Users\ProgFolder
del *.tmp

Step 2: Custom inventory rule for reporting
Name it something meaningful ProgName .tmp list
ShellCommandTextReturn(cmd.exe /c type c:\PG_tmp_list.txt)

Step 3: Create report using KACE report wizard
Select “Computer” report topic
Click “Next”
Select “System Name”
Select “ProgName .tmp list” from the custom fields
Click “Next”
Chose field order
Click “Next”
Chose sort order
Click “Next”
Define a filter
ProgName .tmp list is NOT NULL (because I don’t care about the computers that didn’t have any .tmp files in the directory)
Click “Save”

Here’s my report in SQL:

SELECT MACHINE.NAME AS SYSTEM_NAME,(SELECT MACHINE_CUSTOM_INVENTORY.STR_FIELD_VALUE FROM MACHINE_CUSTOM_INVENTORY WHERE MACHINE_CUSTOM_INVENTORY.ID=MACHINE.ID AND MACHINE_CUSTOM_INVENTORY.SOFTWARE_ID=11763) AS MACHINE_CUSTOM_INVENTORY_0_11763,(SELECT MACHINE_CUSTOM_INVENTORY.STR_FIELD_VALUE FROM MACHINE_CUSTOM_INVENTORY WHERE MACHINE_CUSTOM_INVENTORY.ID=MACHINE.ID AND MACHINE_CUSTOM_INVENTORY.SOFTWARE_ID=13566) AS MACHINE_CUSTOM_INVENTORY_0_13566 FROM MACHINE    WHERE ((1  in (select 1 from MACHINE_CUSTOM_INVENTORY where MACHINE.ID = MACHINE_CUSTOM_INVENTORY.ID and MACHINE_CUSTOM_INVENTORY.SOFTWARE_ID = 13566 and MACHINE_CUSTOM_INVENTORY.STR_FIELD_VALUE is not null)) )  ORDER BY SYSTEM_NAME

Afterthoughts:
I realize now looking back that I wish my text file also included the dates of the .tmp files so we’d be able to confirm that upgrading to the newer version of the software actually fixed the issue of the stored temp files. Aside from that, I'm happy and most importantly my customer is happy.


Comments

  • Great Article!

    Here is an article that I created using custom inventory rules to search and inventory what version of IE is installed. Maybe your readers can find it helpful!

    http://www.itninja.com/blog/view/kace-custom-inventory-rules-101 - c_brock 11 years ago
This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ