Deploy Cube or SSAS solution to any Remote Server using PowerShell
Use the following code by providing:
- Server Name
- Deployment File path
- Cube Name
- Analysis Services Database
This PowerShell script can also be used for configuring Release Management or Release Management Online (RMO)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param | |
( | |
$ServerName, | |
$CubeName, | |
$FilePath, | |
$ASDatabaseFileName | |
) | |
Function DeployCube ($AsdatabaseFilePath) | |
{ | |
Microsoft.AnalysisServices.Deployment.exe $AsdatabaseFilePath /s | |
"Deployment of $CubeName to $ServerName completed." | |
} | |
# Start deployment | |
################################################################################## | |
# Initialize the default script exit code. | |
try | |
{ | |
#Deployment of Cube_DataSources on $ServerName started | |
$scriptpath = $MyInvocation.MyCommand.Path | |
$dir = Split-Path $scriptpath | |
$destination = Split-Path -Path $dir -Parent | |
$loc= $destination + $FilePath + $ASDatabaseFileName + '.deploymentoptions' | |
[xml]$CubeXML = Get-Content $loc | |
$CubeXML.DeploymentOptions.ProcessingOption = 'DoNotProcess' | |
$CubeXML.Save($loc) | |
$targetPath = $destination + $FilePath + $ASDatabaseFileName + '.deploymenttargets' | |
[xml]$CubeXML = Get-Content $targetPath | |
$CubeXML.DeploymentTarget.Database = $CubeName | |
$CubeXML.DeploymentTarget.Server = $ServerName | |
$CubeXML.DeploymentTarget.ConnectionString = 'DataSource=' + $ServerName + ';Timeout=0' | |
$CubeXML.Save($targetPath) | |
$Filename = $destination + $FilePath + $AsdatabaseFileName + '.asdatabase' | |
#Write Output $Filename | |
DeployCube ($Filename) | |
$exitCode=0; | |
} | |
catch | |
{ | |
$exitCode= -1; | |
$_.Exception.Message; | |
} | |
################################################################################## | |
# Indicate the resulting exit code to the calling process. | |
if ($exitCode -lt 0) | |
{ | |
"`nERROR: Operation failed with error code $exitCode." | |
} | |
"`nDone." | |
exit $exitCode |