I have two log files files as such with in a folder
foo.log20140905 9/5/2014 11:04 PM LOG20140905 File 649kb
foo.log20140906 9/6/2014 11:04 PM LOG20140906 File 916kb
when I run my script on 6th I should be able to get content of the the file from 5th
Get-Content "\\Server\LogFiles\foo_pilot\foo.log20140905"
foo_pilot is the folder which has collection of all the log files dated as shown above. the script should pic the previous days file when its runs on the present day. I was able to hard code it and get it but should automate the process. Any help on this.
I tried with the code below by replacing the foo.log20140905 with the "where" object as shown below but could not find a solution
Get-ChildItem c:\folder\*.* Where{$._LastWrittenTime -gt (Get-Date).AddDays(-1)}