Calculate the Size of Filebase Buckets using PowerShell
Learn how to calculate the size of Filebase Buckets using PowerShell.
Last updated
Was this helpful?
Learn how to calculate the size of Filebase Buckets using PowerShell.
Last updated
Was this helpful?
PowerShell is a task automation and configuration management program created by Microsoft that consists of a command-line shell interface and a built-in scripting language. PowerShell is available for operating systems.
Read below to learn how to calculate the size of Filebase Buckets using PowerShell.
Filebase would like to thank Trevor Sullivan from CBTNuggets for the of this tutorial guide.
First, we need to install the Amazon S3 module for use with Filebase. Install this module with the command:
Install-Module -Name AWS.Tools.S3 -Scope CurrentUser -Force
To do this, use the following command:
Set-AWSCredential -StoreAs Filebase -AccessKey ACCESS_KEY -SecretKey SECRET_KEY
Replace the ACCESS_KEY with your Filebase Access Key, and the SECRET_KEY with your Filebase Secret Key.
This command will list the objects stored in your Filebase bucket, then we’ll store it as an environment variable in memory for us to reference after:
$ObjectList = Get-S3Object -BucketName FILEBASE_BUCKET_NAME -EndpointUrl https://s3.filebase.com -Region us-east-1 -ProfileName filebase
Replace FILEBASE_BUCKET_NAME
with your Filebase bucket name.
Then, we can pipe this into another command called Measure-Object which can create a sum of the numeric values we got from the Select-Object -Property Size command. Lastly, we’ll save this entire output as the $Sum variable:
$Sum = $ObjectList | Select-Object -ExpandProperty Size | Measure-Object -Sum
$Sum.Sum
This value might be hard to read if you have a large amount of data stored in your bucket, so we can refine this output by Gigabytes with the following filter:
$Sum.Sum/1GB
Here’s a bit of code that can accomplish just that: