Splunk Search

How to search in active directory for servers connected in the last 14 days?

numeroinconnu12
Path Finder

Hello and happy new year to all,

As the title says I would like to have the list of servers that have connected over the last 14 days (Lastlogon)... I have tried several methods but nothing works, here is my query : 

index=msad  SamAccountName=*$ VersionOS="Windows Server*"
| eval llt=strptime(LastLogon,"%d/%m/%Y %H:%M:%S")
| eval LastLogon2=strftime(llt, "%d/%m/%Y %H:%M:%S")
| rex field=SamAccountName mode=sed "s/\$//g"
| table Domain,SamAccountName,VersionOS,LastLogon2

Thanks 

Labels (1)
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

You created the llt field, but didn't do anything with it.  Use the relative_time function to see how old llt is.

index=msad  SamAccountName=*$ VersionOS="Windows Server*"
| eval llt=strptime(LastLogon,"%d/%m/%Y %H:%M:%S")
| where llt > relative_time(now(), "-14d")
| rex field=SamAccountName mode=sed "s/\$//g"
| table Domain,SamAccountName,VersionOS,LastLogon

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

numeroinconnu12
Path Finder

thank you very much, it's works@richgalloway

richgalloway
SplunkTrust
SplunkTrust

You created the llt field, but didn't do anything with it.  Use the relative_time function to see how old llt is.

index=msad  SamAccountName=*$ VersionOS="Windows Server*"
| eval llt=strptime(LastLogon,"%d/%m/%Y %H:%M:%S")
| where llt > relative_time(now(), "-14d")
| rex field=SamAccountName mode=sed "s/\$//g"
| table Domain,SamAccountName,VersionOS,LastLogon

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...