Hi, I've created a script that compares two files in different directories. The aim of the script is, it searches a network location directory and compares it to a local directory, if the file in the network location is newer ("going by date created") than the one stored locally. It copies it into the local directory. Here is my code
$source = import-csv -Path "c:\network.csv" $destination = import-csv -Path "c:\local.csv" $output = @() forEach ($row in $source) { $result = $destination | Where-Object {$row.Name -eq $_.Name} if ($row.CreationTime -gt $result.CreationTime) { write-host "Found Change" write-host $row.Name, $row.CreationTime write-host $result.Name, $result.CreationTime $output += New-object PSObject -property @{ FileName = $row.Name CreationTime = $row.CreationTime } } } $output | select-object FileName | Export-Csv -Path C:\Changes.csv -NoTypeInformation $NewVersions = import-csv -Path "C:\changes.csv" forEach ($row in $NewVersions) { $filename = $row.FileName }The problem is that, it seems to be comparing the 2 creation dates as different times. How would I alter this code to compare the dates created not the times?
- Edited by rundownbassman92 Wednesday, August 19, 2015 12:15 PM