Define variables $localPath = "C:\path\to\your\local\directory" $s3Bucket =…
- User
Define variables
s3Bucket = "your-s3-bucket-name" #$awsProfile = "your-aws-profile" # Optional, if you use AWS profiles
Get the current date and calculate the date 7 days ago
cutoffDate = $currentDate.AddDays(-7)
- Assistant
This PowerShell script moves files from a local directory to an S3 bucket if they are older than 7 days. Here’s what each part of the script is doing:
-
Define Variables:
$localPathis the path to the local directory containing the files you want to check.$s3Bucketis the name of the S3 bucket where you want to move the files.$awsProfileis commented out but can be used if you have multiple AWS profiles configured.
-