Last active
December 24, 2015 15:09
-
-
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.
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
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