How to filter and download files from S3 in powershell
12:57 10 Mar 2020

I am trying to create a script that will search all of our backup files and grab just the latest backup to download.

I know i can use get-s3object to search get files but there is no way to filter them To make sure i get a current backup file.

i have tried this. But it doesn't return any inforamtion. Is there a way to filter/search s3 for files that match a certain name

$path = Get-S3object -BucketName $Bucket
    foreach ($data in $database)
{

#For testing use the QBW filter
#Once testing is over swithc to proper filter.
$filter = "*$($server)_$($data)_FULL*"
$latest = get-childitem -Path $path -Filter $filter |
    where-object { -not $_.PSIsContainer } |
    sort-object  LastAccessTime -Descending |
    Select-Object -first 1
write-output $latest.fullname
Write-Output $filter}

I have tried to save the s3 bucket keys and then filter them but i was unable to figure out how to properly get that info saved to memory and search.

powershell amazon-s3