Hoping you can help. The below script copies all files from a folder structure then pastes them to an S3 bucket. However I want it to be able to skip files that have not been changed etc to avoid duplicating the upload. Does anyone know how I can get a if file exists check or last modified?
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
}
}
Aucun commentaire:
Enregistrer un commentaire