Solved

how to retrieve files of a specific date

Posted on 2016-07-27
5
42 Views
Last Modified: 2016-07-28
Hi I'm trying to list all files which have been modified on a specific date.  I would have thought this would be quite a simple and common task in powershell but as always...

I have come up with the following code but unfortunately it doesn't return anything even though I know there are files there with that last write time

Get-ChildItem "C:\Users\jsmith" | Where-Object {$_.LastWriteTime.Date -eq "17/05/2016"} | ForEach-Object {$_.FullName, $_.LastWriteTime}

Open in new window

0
Comment
Question by:carbonbase
5 Comments
 
LVL 83

Assisted Solution

by:oBdA
oBdA earned 125 total points
ID: 41731269
Should work (it does for me), provided your date format is correct.
Could it be that you forgot the -recurse switch for Get-ChildItem? You're only looking in the root of "C:\Users\jsmith".
0
 
LVL 52

Assisted Solution

by:Bill Prew
Bill Prew earned 125 total points
ID: 41731273
Works okay here, once I adjust the date format, is that correct for your system?

Also, keep in mind folders in that base directory will be shown as well if they were last changed on that date, not sure if you want that or just files?

Also, you are only looking in the root folder you specified, you would need to add -recurse to drill into subfolders.

~bp
0
 
LVL 45

Accepted Solution

by:
aikimark earned 250 total points
ID: 41731958
As Bill Prew hinted, you need to use mm/dd/yyyy formatted dates or a date object
0
 

Author Closing Comment

by:carbonbase
ID: 41732829
Thanks for your comments guys.  So in the code I need to specify the date in US date format, even though the results display in my localised (UK) date format.
0
 

Author Comment

by:carbonbase
ID: 41732834
So for reference my code now looks like this:

 Get-ChildItem -Recurse "C:\Users\jsmith" | Where-Object {!($_.PSIsContainer)} | Where-Object {$_.LastWriteTime.Date -eq "05/17/2016"} | ForEach-Object {$_.FullName, $_.LastWriteTime}

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Set OWA language and time zone in Exchange for individuals, all users or per database.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now