This PowerShell script can be used to deploy a Cube or a Tabular Model solution to any Server (local/remote) using PowerShell.
Run the script below by updating the following parameters:
- Server Name
- Deployment File path
- Cube Name
- Analysis Services Database
This PowerShell script can also be used for configuring Release Management, Release Management Online (RMO) and other various Build Pipelines.
Script
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