Solved

how to retrieve files of a specific date

Posted on 2016-07-27
5
64 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 85

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 56

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 46

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

626 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