Skip to content

Instantly share code, notes, and snippets.

@bryankahlig
Last active December 24, 2015 15:09
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 bryankahlig/6818495 to your computer and use it in GitHub Desktop.
Save bryankahlig/6818495 to your computer and use it in GitHub Desktop.
PowerShell script to get the size and number of files on your Rackspace Cloud Files system. Specifically focused on files in the "ORD" region.
function WriteOutFileStats($count, $byteCount){
Write-Host ([string]::Format("Files = {0:N0}", $count))
$gbCount = $byteCount / 1024 / 1024 / 1024
Write-Host ([string]::Format("Size(GB) = {0:N2}", $gbCount))
}
Write-Host "Rackspace------------------------------------------------------------------------------"
Import-Module PowerClient
Get-AuthToken
$rackspaceUrl = ""
foreach ($service in $token.access.serviceCatalog.service)
{
if ($service.name -eq "cloudFiles")
{
foreach ($endpoint in $service.endpoint)
{
if ($endpoint.region -eq "ORD")
{
$rackspaceUrl = $endpoint.publicURL
}
}
}
}
$resp = Invoke-WebRequest -Uri $rackspaceUrl -Headers $HeaderDictionary -Method Head
WriteOutFileStats $resp.Headers["X-Account-Object-Count"] $resp.Headers["X-Account-Bytes-Used"]
Write-Host (Get-Date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment