AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
WithKey (Default)
Remove-S3Object-BucketName <String>-Key <String>-VersionId <String>-RequestPayer <RequestPayer>-SerialNumber <String>-AuthenticationValue <String>-Force <SwitchParameter>-ClientConfig <AmazonS3Config>-UseAccelerateEndpoint <SwitchParameter>-UseDualstackEndpoint <SwitchParameter>-ForcePathStyleAddressing <Boolean>WithKeyVersionCollection
Remove-S3Object-BucketName <String>-KeyAndVersionCollection <KeyVersion[]>-ReportErrorsOnly <SwitchParameter>-ChecksumAlgorithm <ChecksumAlgorithm>-RequestPayer <RequestPayer>-SerialNumber <String>-AuthenticationValue <String>-Force <SwitchParameter>-ClientConfig <AmazonS3Config>-UseAccelerateEndpoint <SwitchParameter>-UseDualstackEndpoint <SwitchParameter>-ForcePathStyleAddressing <Boolean>WithKeyCollection
Remove-S3Object-BucketName <String>-KeyCollection <String[]>-ReportErrorsOnly <SwitchParameter>-ChecksumAlgorithm <ChecksumAlgorithm>-RequestPayer <RequestPayer>-SerialNumber <String>-AuthenticationValue <String>-Force <SwitchParameter>-ClientConfig <AmazonS3Config>-UseAccelerateEndpoint <SwitchParameter>-UseDualstackEndpoint <SwitchParameter>-ForcePathStyleAddressing <Boolean>WithS3ObjectCollection
Remove-S3Object-InputObject <S3Object[]>-ReportErrorsOnly <SwitchParameter>-RequestPayer <RequestPayer>-SerialNumber <String>-AuthenticationValue <String>-Force <SwitchParameter>-ClientConfig <AmazonS3Config>-UseAccelerateEndpoint <SwitchParameter>-UseDualstackEndpoint <SwitchParameter>-ForcePathStyleAddressing <Boolean>
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | MfaCodes_Second |
Required? | True |
Position? | 1 |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | True |
Position? | Named |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Aliases | InputObjects, S3ObjectCollection |
Required? | True |
Position? | 2 |
Accept pipeline input? | True (ByPropertyName) |
Required? | True |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | VersionKeys, VersionKey |
Required? | True |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | Keys |
-KeyCollection
parameter. Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | Quiet |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | MfaCodes_First |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | 3 |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | AK |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | AWSProfilesLocation, ProfilesLocation |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | StoredCredentials, AWSProfileName |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | RegionToCall |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | SK, SecretAccessKey |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | ST |
Remove-S3Object -BucketName amzn-s3-demo-bucket -Key sample.txtThis command removes the object "sample.txt" from bucket "test-files". You are prompted for confirmation before the command executes; to suppress the prompt use the -Force switch.
Remove-S3Object -BucketName amzn-s3-demo-bucket -Key sample.txt -VersionId HLbxnx6V9omT6AQYVpks8mmFKQcejpqtThis command removes the specified version of object "sample.txt" from bucket "test-files", assuming the bucket has been configured to enable object versions.
Remove-S3Object -BucketName amzn-s3-demo-bucket -KeyCollection @( "sample1.txt", "sample2.txt", "sample3.txt" )This command removes objects "sample1.txt", "sample2.txt" and "sample3.txt" from bucket "test-files" as a single batch operation. The service response will list all keys processed, regardless of the success or error status of the deletion. To obtain only errors for keys that were not able to be processed by the service add the -ReportErrorsOnly parameter (this parameter can also be specified with the alias -Quiet.
Remove-S3Object -bucketname "amzn-s3-demo-bucket" -KeyCollection (Get-S3Object "test-files" -KeyPrefix "prefix/subprefix" | select -ExpandProperty Key)This example uses an inline expression with the -KeyCollection parameter to obtain the keys of the objects to delete. Get-S3Object returns a collection of Amazon.S3.Model.S3Object instances, each of which has a Key member of type string identifying the object.
Get-S3Object -BucketName "amzn-s3-demo-bucket" -KeyPrefix "prefix/subprefix" | Remove-S3Object -ForceThis example obtains all objects that have a key prefix "prefix/subprefix" in the bucket and deletes them. Note that the incoming objects are processed one at a time. For large collections consider passing the collection to the cmdlet's -InputObject (alias -S3ObjectCollection) parameter to enable the deletion to occur as a batch with a single call to the service.
(Get-S3Version -BucketName "amzn-s3-demo-bucket").Versions | Where {$_.IsDeleteMarker -eq "True"} | Remove-S3Object -ForceThis example pipes a collection of Amazon.S3.Model.S3ObjectVersion instances that represent delete markers to the cmdlet for deletion. Note that the incoming objects are processed one at a time. For large collections consider passing the collection to the cmdlet's -InputObject (alias -S3ObjectCollection) parameter to enable the deletion to occur as a batch with a single call to the service.
$keyVersions = @()
$markers = (Get-S3Version -BucketName $BucketName).Versions | Where {$_.IsDeleteMarker -eq "True"}
foreach ($marker in $markers) { $keyVersions += @{ Key = $marker.Key; VersionId = $marker.VersionId } }
Remove-S3Object -BucketName $BucketName -KeyAndVersionCollection $keyVersions -ForceThis script shows how to perform a batch delete of a set of objects (in this case delete markers) by constructing an array of objects to be used with the -KeyAndVersionCollection parameter.
AWS Tools for PowerShell: 2.x.y.z