All Apps and Add-ons

Splunk Add-on for Microsoft Windows: How to compare data for Script to Show Software Installation Dates?

mwisniewski9
Explorer

Hello,

I have a question about extracting dates from fields for comparison purposes. I am trying to write a search that shows new windows software installations over the past 30 days.

Currently, the dates installedapps.bat file that is part of the Splunk App for Windows comes back as 20170622,20170627,etc... which is YearMonthDate. I want to compare the InstallDate to Today's date.

What would be the best way to search for only software that has been installed in the past 30 days? I cannot use the _time field because that is just the date the script was run, not the date of the software installation.

Thanks in advance for the help!

0 Karma
1 Solution

adonio
Ultra Champion

hello there,

run this search to see how to convert your time in field to epoch:

| makeresults count=1 
| eval install_dates ="20170622,20170627,20170629,20170703"
| makemv delim="," install_dates
| mvexpand install_dates
| eval install_dates_epoch = strptime(install_dates, "%Y%m%d")

now you can add your condition:

| where install_dates_epoch < relative_time(now(),"-30d@d")

apply this technique to your search

hope it helps

View solution in original post

adonio
Ultra Champion

hello there,

run this search to see how to convert your time in field to epoch:

| makeresults count=1 
| eval install_dates ="20170622,20170627,20170629,20170703"
| makemv delim="," install_dates
| mvexpand install_dates
| eval install_dates_epoch = strptime(install_dates, "%Y%m%d")

now you can add your condition:

| where install_dates_epoch < relative_time(now(),"-30d@d")

apply this technique to your search

hope it helps

mwisniewski9
Explorer

Hi Adonio,

Thanks for response, this is exactly what i was looking for.

I just had to make one minor tweak.
| where install_dates_epoch **>** relative_time(now(),"-30d@d")

Now it's showing me events that happened in the last 30 days

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...