Skip to content

Instantly share code, notes, and snippets.

@trickymast3r
Last active March 7, 2024 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trickymast3r/44d3cfcfde123b7a3814af485eca419d to your computer and use it in GitHub Desktop.
Save trickymast3r/44d3cfcfde123b7a3814af485eca419d to your computer and use it in GitHub Desktop.
Powershell Awesome
Add-Type -Path "C:\Program Files\AWS SDK for .NET\bin\AWSSDK.dll"
$secretKeyID="secretkeyid"
$secretAccessKeyID="accesskeyid"
$client=[Amazon.AWSClientFactory]::CreateAmazonS3Client($secretAccessKeyID,$secretKeyID)
$backup_directory="C:\target\"
foreach($file in Get-ChildItem -Path $backup_directory){
$request = New-Object -TypeName Amazon.S3.Model.PutObjectRequest
[void]$request.WithFilePath($file.fullname)
[void]$request.WithBucketName("bucketname")
[void]$request.WithKey($file.name)
[void]$request.WithTimeout(3600000)
[void]$client.PutObject($request)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment