-
-
Save TinyToons/e9d6d4d5902965b0d1b034399a613a8d to your computer and use it in GitHub Desktop.
Get Analysis Services databases size
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
<# | |
.SYNOPSIS | |
Export Power BI Model Size | |
.DESCRIPTION | |
#> | |
function Export-ModelSize{ | |
param( | |
[string]$OutputFolder | |
) | |
Write-Host "Exporting Model Size..." | |
$ServerName="SSASServer\SSASInstance" | |
$loadInfo = [Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") | |
$outputfile = "$OutputFolder\PBIRS_ModelSize.csv" | |
if (Test-Path $outputfile) { | |
Remove-Item $outputfile | |
} | |
$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 ){ | |
New-Object PSObject -Property @{ | |
Name = $d.Name; | |
ItemID = $d.Name.SubString(0,36); # Mapping to the ItemID column from Catalog table | |
SizeMB = [math]::Round($d.EstimatedSize/1024/1024,2); | |
} | export-csv -Path $outputfile -NoTypeInformation -Append | |
} | |
} |
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
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