Created
June 9, 2021 23:49
-
-
Save krymtkts/31a4a9399901b2996d37cd1f2ed2039f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true)] | |
[string] | |
$BucketName, | |
[Parameter()] | |
[string] | |
$Prefix, | |
[Parameter(Mandatory = $true)] | |
[ValidateRange("NonNegative")] | |
[int] | |
$Level | |
) | |
$params = @{ | |
"BucketName" = "$BucketName"; | |
} | |
if ($Prefix -ne "") { | |
$params["Prefix"] = $Prefix | |
} | |
Get-S3Object @params | ForEach-Object -Process { try { $_.Key.Split('/')[$Level] } catch {} } | Group-Object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment