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

How to manipulate multiple files in a folder

$
0
0

I have this code:

 

$whatdate = (Get-Date).Date

$today = $whatdate.ToShortDateString()

$file = (Get-Item 'C:\pstfiles\file1.pst').LastWriteTime.ToShortDateString()

foreach ($pst in $file)  {$today -like $file}

 

File1.pst in this case was modified today.  When I run this code it will return TRUE.

 

if I change my Get-Item to read like this:

(Get-Item 'C:\pstfiles\*.pst').LastWriteTime.ToShortDateString()

it returns the following.

 

FALSE

FALSE

FALSE

 

I have 3 files in my folder.  File1 modified today.  File2 & File3 were modified yesterday.    Why would my code return FALSE 3 times?   It should return FALSE, FALSE, TRUE

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles