You can do it using powershell.

    $serverName = "servername\instanceName" 
    $outputFolder = "D:\data\"
    
    ## load the AMO and XML assemblies into the current runspace 
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") > $null 
    [System.Reflection.Assembly]::LoadWithPartialName("System.Xml") > $null 
    $dateStamp = (get-Date).ToString("yyyyMMdd")
    
    ## connect to the server 
    $svr = new-Object Microsoft.AnalysisServices.Server 
    $svr.Connect($serverName) 
    foreach ($db in $svr.Databases) 
    { 
        write-Host "Scripting: " $db.Name 
        $xw = new-object System.Xml.XmlTextWriter("$($outputFolder)DBScript_$($db.Name)_$($dateStamp).xmla", [System.Text.Encoding]::UTF8) 
        $xw.Formatting = [System.Xml.Formatting]::Indented 
        [Microsoft.AnalysisServices.Scripter]::WriteCreate($xw,$svr,$db,$true,$true) 
        $xw.Close() 
    } 
    $svr.Disconnect()


References : 

 - [Automating the Scripting of an SSAS database][1]
 - [PowerShell to Script SQL Analysis Service Database(XMLA Script) and ReApply on a different Server][2]
 - [SQL Server Analysis Services Backup in Powershell][3]


  [1]: http://geekswithblogs.net/darrengosbell/archive/2010/02/22/ssas-automating-the-scripting-of-an-ssas-database.aspx
  [2]: http://www.sqltechnet.com/2013/08/powershell-to-script-sql-analysis.html
  [3]: https://zakird.com/code/2011/06/20/backing-up-analysis-services-in-powershell/