Deploying to SQL Server Analysis Services (SSAS) using PowerShell

My previous post was about configuring http access to SSAS. Here is a way to deploy a SSAS project using script (PowerShell) via http.

First, create a project configuration. I called mine “Test”. Then, edit the “.deploymenttargets” file located in the project configuration folder in the bin folder (MyProject\bin\Test in my case). Edit the server parameter to e.g.

https://myserver.cloudapp.net/OLAP/msmdpump.dll

Then, create a deployment script using the deployment utility:

“C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Microsoft.AnalysisServices.Deployment” MyProject\bin\Test\Model.asdatabase /s:ScriptLog.txt /o:Model.xmla /d

Then, deploy using the new PowerShell commandlets:

$credential = Get-Credential domain\user
Invoke-ASCmd -InputFile $fspath\Model.xmla -Server https://myserver.cloudapp.net/OLAP/msmdpump.dll -Credential $credential

Here is the entire script:

$fspath = (Get-Location).Path
Write-Host "Generating deployment script..."
& "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Microsoft.AnalysisServices.Deployment" MyProjct\bin\Test\Model.asdatabase /s:ScriptLog.txt /o:Model.xmla /d
Start-Process $fspath\ScriptLog.txt
Write-Host "Importing SQL modules..."
Import-Module SQLPS -disablenamechecking
Import-Module sqlascmdlets
Write-Host "Invoking deployment script... This may take several minutes or even hours."
$credential = Get-Credential domain\user
Invoke-ASCmd -InputFile $fspath\Model.xmla -Server https://myserver.cloudapp.net/OLAP/msmdpump.dll -Credential $credential | Out-File $fspath\Result.xml
Start-Process $fspath\Result.xml
Write-Host "Done."
Advertisements

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