Recently, our Asset Management department expressed a desire to not only report whether or not a workstation had software installed, but also when it was last used. This information can be valuable as it would allow us to repurpose existing unused licenses rather than needlessly purchasing additional seats.
As a result, I was able to create an Extension Attribute for each application we wanted to report on by using the following code example. The Extension Attribute should be created to return a Date (Data Type) and will function in the following way:
- IF the application is not installed, return "Not Present".
- IF the application is installed, return the date and time it was last opened.
- IF the application is installed, but NEVER opened, return "2001-01-01".
By using the Date (Data Type), this allows us to leverage Advanced Computer Searches to look for infrequently used software. For example, we could create an Advanced Computer Search to look for all instances of iMovie that have not been launched in more than 90 days and who's Last Inventory Update was less than 5 days ago.
So far, this has given us great insight into what our users are actually using on their workstations and helping us save a little time and money as well when it comes to license procurement or testing resources.
And because of that, I wanted to share it with the community. Enjoy!
#!/bin/bash
APPLICATION_PATH=/Applications/Self Service.app
if [ ! -e "$APPLICATION_PATH" ]; then
result="Not Present"
fi
if [ -e "$APPLICATION_PATH" ]; then
result=`mdls "$APPLICATION_PATH" | grep kMDItemLastUsedDate | awk '{ $1 = $1 } { print }' | cut -c 23-41`
fi
if [ "$result" == "" ]; then
result="2001-01-01 01:01:01"
fi
echo "<result>$result</result>"