你的位置:首页 > 数据库

[数据库]Powershell查看SSAS Cube占用磁盘空间


以下是用powershell查看Cube占用磁盘空间大小的方式。可以编译成函数也可以直接把参数改成需要的服务器名称。

Param($ServerName="SERVERNAME")$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=0foreach ($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 } $SizeGB=$Sum/1024 write-host 'Sum of Database = '$sum 'MB'Write-host 'Total Size of Cube Databases =' $SizeGB 'GB'

 

结果

image