Solved

how to retrieve files of a specific date

Posted on 2016-07-27
5
50 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 53

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

816 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

9 Experts available now in Live!

Get 1:1 Help Now