I' am trying to put together a PowerShell script that will allow me to upload files to my AWS S3 Bucket based on the last modified date of a folder.
This is what i have thus far:
using namespace System.IO;
Set-AWSCredentials -StoredCredentials MyCredentialsAws
Set-DefaultAWSRegion us-east-1
[String] $root = "C:\Users\Administrator\Documents\TestFolder";
[DateTime]$today = [DateTime]::Now.Date;
[FileSystemInfo[]]$folderList = Get-ChildItem -Path $root -Directory;
foreach( $folder in $folderList ) {
if( $folder.LastWriteTime -lt $today ) {
[String] $folderPath = $folder.FullName;
aws s3 cp $folder s3://bucketname/$folder --recursive
}
}
However, the above gives me the error:
"The User-provided path does not exist"
Any help would be appreciated.