Get CubeInfo

Hello!

Here’s a simple Powershell script here to get the top level info of the cubes on an instance. This is a good script to understand how to use the AMO namespace to get info on the cubes via Powershell. You can add many other properties to this list to expand the info that you want. I’ve often mused about moving a lot of the logic that I constantly put in these scripts into higher tier functions in Powershell, or even create a ssas library, but time is always a premium…

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, or run through Powershell ISE. 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.


[CmdletBinding()]
param(
[Parameter(Position=0,mandatory=$true)]
[string] $ssasInstance)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$server = New-Object Microsoft.AnalysisServices.Server
$server.connect($ssasInstance)
$database=$server.databases
foreach ($db in $server.databases)
{
$Cubes=New-object Microsoft.AnalysisServices.Cube
$Cubes=$db.cubes
foreach ($cub in $cubes)
{
$cubewriteout = $Cub|select name,state,lastprocessed,parent
write-output $cubewriteout | format-list
}
}

Here’s a screenshot:

2014-10-16 16_27_40-Windows PowerShell ISE

Author: Richie Lee

Full time computer guy, part time runner. Full time Dad, part time blogger. Knows a thing or two about Pokémon. Knows too much about SQL Agent. Writer of fractured sentences. Maker of the best damn macaroni cheese you've ever tasted.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s