以下脚本从文件夹结构复制所有文件,然后将它们粘贴到 S3 存储桶。但是我希望它能够跳过自上次上传以来未更改的文件,以避免重复上传。有谁知道我如何获得文件是否存在检查或上次修改?
Import-Module "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1"
$bucket="bucketname"
$source="e:\dfs\*"
$outputpath="C:\temp\log.txt"
$AKey="xxxx"
$SKey="xxxx"
Set-AWSCredentials -AccessKey $AKey -SecretKey $SKey -StoreAs For_Move
Initialize-AWSDefaults -ProfileName For_Move -Region eu-west-1
Start-Transcript -path $outputpath -Force
foreach ($i in Get-ChildItem $source -include *.* -recurse)
{
if ($i.CreationTime -lt ($(Get-Date).AddDays(-0)))
{
$fileName = (Get-ChildItem $i).Name
$parentFolderName = Split-Path $i -Parent
Write-S3Object -BucketName $bucket -Key dfs/$parentFolderName/$filename -File $i
}
}