Solved

how to retrieve files of a specific date

Posted on 2016-07-27
5
38 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 51

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

11 Experts available now in Live!

Get 1:1 Help Now