Page 1 of 1

Check for new or modified files

Posted: Tue Aug 03, 2021 9:02 am
by hbouma
We are being asked to check a Windows system for any new files or modified files created under a directory and its subdirectories.

I have been unsuccessful in creating my own plugin or finding a plugin so far that will work. Does anyone know of a plugin that does this, or have any suggestions about a plugin that may do what I need?

For our purposes, a modification to the date/time stamp will be enough to justify a failure condition, as well as a new file being created.

Re: Check for new or modified files

Posted: Tue Aug 03, 2021 3:23 pm
by gsmith
Hi

You could do something like this Powershell script:

Code: Select all

 Get-ChildItem -Path C:\ -Exclude 'C:\Windows\*','C:\PerfLogs\*' -File -Recurse | Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-10/1440)}  | Select -First 1

where
-Exclude = skip these locations

{$_.LastWriteTime -gt (Get-Date).AddDays(-10/1440)} = get files modified in the last 10 minutes (10/1440)

Select -First 1 = stop after you find one. Don't use this if you want a list of files that are 10 minutes old or younger

Obviously there is more to it than this, but you could look at other powershell plugins to get how to
return required variables, etc.

Thanks