This article describes a file-by-file modification time in a PowerShell to find files, using the LastWriteTime property of the file object.
In many cases, I need to find the files by the time I change them. For example, a website, recently found to be hanging horse, we may look at the recent backup has been modified, so as to determine the approximate time period of black. With this time period, we want to see what files have been modified within this period of time, what new files, it is likely that hackers left a word trojan, and even the big horse in the inside.
Let's look at how PowerShell can find files based on the file modification time.
Small series first to see what the D-packing directory under what content:
Copy Code code as follows:
PS c:\users\splaybow> dir d:
Table of Contents: D:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
D----2013/11/1 22:27 Green
D----2013/11/4 17:31 program Files
D----2013/11/6 10:23 program Files (x86)
D----2013/10/13 10:02 soft
Because the small series does not use the-recurse parameter, there is no looping list of subdirectories. If we look up all the files in a directory, we should take this parameter after dir. Now get altogether is four directories. All right, let's sift through the change time before 2013-11-4 file (or directory). Note that the following command uses the pipe to filter the directories listed by Dir to find out if the lastwritetime is less than 2013-11-4, and if it is less than, it must not be included. The results were as follows:
Copy Code code as follows:
PS c:\users\splaybow> dir d: |? {$_.lastwritetime-lt ' 2013-11-4 '}
Table of Contents: D:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
D----2013/11/1 22:27 Green
D----2013/10/13 10:02 soft
Although I just search the directory by the time, but for the file, operation or command is actually exactly the same. So you can rest assured that this command is used to search for files of a specified time period.
About PowerShell according to the modified time to find files, this article on the introduction so much, I hope to help you, thank you!