0

I'm using below function to execute my xmla file against a SSAS instance. $Xmla is a file that creates a db. When i execute this function, the script runs but towards the end it just opens this $Xmla file and does nothing. Also the machine running this script will not have any SQL installed as this will be run on a remote SSAS. This was my source for this function: https://jorgecandeias.github.io/2013/12/24/how-to-execute-xmla-against-ssas-in-powershell/ Am I missing anything?

function Execute-Xmla
{
    [CmdletBinding()]
    param
    (
        [Parameter(Position=0, Mandatory=$True)] [string] $TargetServerName,
        [Parameter(Position=1, Mandatory=$True, ValueFromPipeline=$True)] [string] $Xmla
    )
    begin
   {

        $ConnectionectionString = "Data Source=$TargetServerName;Provider=MSOLAP.4;Integrated Security=SSPI;Impersonation Level=Impersonate;"
        $Connection = New-Object Microsoft.AnalysisServices.AdomdClient.AdomdConnection($ConnectionectionString)
        $Connection.Open();
    }
    process
    {
        $Comand = $Connection.CreateCommand();
        $Comand.CommandTimeout = 20000;
        $Comand.CommandType = [System.Data.CommandType]::Text;
        $Comand.CommandText = $Xmla;
        $Reader = $Comand.ExecuteXmlReader();
        if($Reader.Read())
        {
            $Return = $Reader.ReadOuterXml();
        }
    return $Return;
   }
    end
    {
        $Connection.Close();
        $Connection.Dispose();
    }
};
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
Tag
  • 209
  • 1
  • 3
  • 7

0 Answers0