Processing SSAS Databases Using PowerShell

Late night maintenance on databases also means I get to write a blog post during the downtime. Tonight’s blog post is more PowerShell/SSAS: following on from calculating the size of dimensions and Finding Unprocessed Objects, here’s a PowerShell script that will process all the databases on a given instance that match the current process state you input: If you’ve deployed all the databases to an instance, entering Unprocessed for $CurrentProcessState and ProcessFull for $TypeOfProcess will process all the objects. This is great for overnight batching of processing. I’ve also used this script to apply changes and then run a ProcessDefault on a database that is PartiallyProcessed and it seems to have worked well.

[string] $ssasInstance,
[string] $CurrentProcessState,
[string] $TypeOfProcess)

$server = New-Object Microsoft.AnalysisServices.Server
$database|select-object name
foreach ($db in $database)
if ($db.state -eq $CurrentProcessState)
write-host "---------------------------------------------"
Write-host "Processing Client: $db " -foregroundcolor darkgreen -backgroundcolor white
write-host "Processing took "  ($date2-$date1).Hours " Hours, " ($date2-$date1).Minutes " Mins, " ($date2-$date1).Seconds " Secs " -foregroundcolor darkgreen -backgroundcolor white
$dbwriteout = $db|select name,state,lastprocessed
write-host $dbwriteout -foregroundcolor darkgreen -backgroundcolor white
write-host "No Processing required for database $db" -foregroundcolor yellow -backgroundcolor darkcyan

I’m actually running this as I type; automation is a great way to give me more time to

  1. automate other things
  2. write blog posts
  3. read the internet

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, the CurrentProcessType of your database and which Processing option you want, hit enter and off it goes.

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: Logo

You are commenting using your 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