Avatar of carbonbase
carbonbaseFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

how to retrieve files of a specific date

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

Powershell

Avatar of undefined
Last Comment
carbonbase
SOLUTION
Avatar of oBdA
oBdA

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of Bill Prew
Bill Prew

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of carbonbase
carbonbase
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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.
Avatar of carbonbase
carbonbase
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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

Powershell
Powershell

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

27K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo