Description
Describe the bug
Using Write-S3BucketInventoryConfiguration with explicit parameters always results in "Write-S3BucketInventoryConfiguration: The XML you provided was not well-formed or did not validate against our published schema" when used either with named parameters or splatting.
Code attempted:
$regionId = "us-east-2"
$awsProfile = "psample"
$analyticsBucket = "bsample"
# Create Analytics Bucket
New-S3Bucket -ProfileName $awsProfile -BucketName $analyticsBucket -Region $regionId -ObjectLockEnabledForBucket $true
# List all S3 buckets and enable S3 Inventory and Logging
$buckets = Get-S3Bucket -ProfileName $awsProfile | Select-Object -ExpandProperty BucketName
foreach ($bucket in $buckets) {
$inventoryConfig = @{
ProfileName = $awsProfile
BucketName = $bucket
InventoryId = "1111S3Inventory"
InventoryConfiguration_IsEnabled = $true
S3BucketDestination_BucketName = $analyticsBucket
S3BucketDestination_Prefix = "inventory-reports/"
S3BucketDestination_InventoryFormat = "CSV"
InventoryConfiguration_IncludedObjectVersion = "All"
Schedule_Frequency = "Weekly"
InventoryConfiguration_InventoryOptionalField = @("Size", "LastModifiedDate", "StorageClass", "ETag", "IsMultipartUploaded", "ReplicationStatus", "EncryptionStatus")
}
Write-S3BucketInventoryConfiguration @inventoryConfig
$loggingConfig = @{
ProfileName = $awsProfile
BucketName = $bucket
LoggingConfig_TargetBucketName = $analyticsBucket
LoggingConfig_TargetPrefix = "access-logs/"
}
Write-S3BucketLogging @loggingConfig
}
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
The code should result in a s3 inventory policy being applied to sample bucket
Current Behavior
It errors out
Reproduction Steps
See code above or use
Write-S3BucketInventoryConfiguration -BucketName $S3BucketDestination_BucketName -ProfileName $profile -InventoryId "InventoryConfig" -InventoryConfiguration_IsEnabled $true -InventoryConfiguration_IncludedObjectVersion "All" -S3BucketDestination_BucketName $analyticsBucket -S3BucketDestination_Prefix "inventory-reports/" -S3BucketDestination_InventoryFormat "CSV" -Schedule_Frequency "Weekly"
Possible Solution
- Fix how the parameters should align to the XML the S3 API is expecting
- Provide more useful output in the error
- Provide Examples for use in the help documentation for the cmdlet
Additional Information/Context
https://docs.aws.amazon.com/powershell/v4/reference/items/Write-S3BucketInventoryConfiguration.html
AWS Tools for PowerShell version used
4.1.840
PowerShell version used
PSVersion 7.5.1
PSEdition Core
GitCommitId 7.5.1
OS Darwin 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:29 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Operating System and version
MacOS 15.5