Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

compare write time of files

$
0
0

I need to compare a file with today's date.  If the file date is today's date then copy file.  If the file date is 1 day old or older do nothing.

 

(Get-Item 'C:\pstfiles\MyMailFile.pst').LastWriteTime.ToString()'

That gets the date/time of the file.  The output if this is:  7/24/2014 3:03:32 PM

 

How do I strip off the time?  I only want the date.

 

 

I then have the (get-date).date  command.   I ran this and it returned Friday, July 25, 2014 12:00:00 AM   Notice the time is wrong?  Why? I ran this at 6:10AM yet it says midnight.

 

how do I strip off the time on this as well and then compare the two?

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles