Find Unprocessed Analysis Services Objects Using PowerShell
[CmdletBinding()]
param(
[Parameter(Position=0,mandatory=$true)]
[string] $ssasInstance)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$svr = new-Object Microsoft.AnalysisServices.Server
$svr.Connect($ssasInstance)
foreach ($db in $svr.Databases)
{
if ($db.State -ne "Processed")
{
write-host "-------------------------------------------------------------------------------------------------------------------------" -foregroundcolor yellow -backgroundcolor darkcyan
write-host
write-host "Database" $svr $db "is" $db.State
write-host
$Cub=New-object Microsoft.AnalysisServices.Cube
foreach ($cub in $db.Cubes)
{
if ($cub.State -ne "Processed")
{
write-host $db "Cube" $cub "is" $Cub.State
write-host
foreach ($mg in $cub.MeasureGroups)
{
if ($mg.State -ne "Processed")
{
write-host $db $Cub "Measure Group"$mg "is" $mg.State
write-host
foreach ($p in $mg.Partitions)
{
if ($p.State -ne "Processed")
{
write-host $db $Cub $mg "Partition"$p "is" $p.State
write-host
}
}
}
}
}
foreach ($dim in $db.Dimensions)
{
if ($Dim.State -ne "Processed")
{
write-host $db "Dimension" $Dim "is" $Dim.State
write-host
}
}
}
Write-host "End of checking database "$db
write-host "-------------------------------------------------------------------------------------------------------------------------" -foregroundcolor yellow -backgroundcolor darkcyan
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
write-host
}
}
Write-host "End of checking Instance" $svr
Write-Host
$svr.disconnect
Once you have saved this to a .ps1 file you open up a PowerShell console and drag and drop the file there (or copy as path, whichever way you like) and press enter. It’ll ask you for the ssasInstance, and then hit enter and off it goes. The thing I like about checking cube status this way is that it is so much quicker than going through the UI.
It’s interesting to note that you can check the state of the dimensions within the first foreach loop of the cubes, however you cannot get the state. Why I have no idea, but I hazard a guess that it’s because a dimension is not strictly speaking part of a cube.