Skip to content

Instantly share code, notes, and snippets.

@ghotz
Created July 15, 2015 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ghotz/369ac83ccfd8d8836061 to your computer and use it in GitHub Desktop.
Save ghotz/369ac83ccfd8d8836061 to your computer and use it in GitHub Desktop.
Get Analysis Services databases size
Param($ServerName="GSRVBI1")
cls
$loadInfo = [Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$server = New-Object Microsoft.AnalysisServices.Server
$server.connect($ServerName)
if ($server.name -eq $null) {
Write-Output ("Server [{0}] not found" -f $ServerName)
break
}
$sum = 0
foreach ($d in $server.Databases)
{
Write-Output ("Database: {0}; Status: {1}; Size: {2}MB" -f $d.Name, $d.State, ($d.EstimatedSize/1024/1024).ToString("#,##0"))
$sum = $sum + $d.EstimatedSize / 1024 / 1024
}
Write-Output ("Total size: {0}MB" -f $sum.ToString("#,##0"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment