So technically when you right click on a 1400 compatibility level database you don't get an XMLA script you get a JSON based TMSL script. But assuming that is what you meant you could use a script like the following.
Note that this script loads the AMO assemblies from the GAC on the local machine. If you need to use new versions of these libraries you could download them from nuget and replace the LoadWithPartialName() calls at the top of the script with LoadFile() calls
# load the AMO Tabular assemblies into the current runspace
$assembly = [System.Reflection.Assembly]
$assembly::LoadWithPartialName("Microsoft.AnalysisServices.Tabular") > $null
$assembly::LoadWithPartialName("Microsoft.AnalysisServices.Tabular.Json") > $null
$serverName = "localhost\tab19"
$outputFolder = "C:\temp\"
$dateStamp = (get-Date).Tostring("yyyyMMdd")
# connect to the server
$svr = new-Object Microsoft.AnalysisServices.Tabular.Server
$svr.Connect($serverName)
foreach ($db in $svr.Databases)
{
write-Host "Scripting: " $db.Name
$scriptFile = "$($outputFolder)DBScript_$($db.Name)_$($dateStamp).xmla"
$opt = [Microsoft.AnalysisServices.Tabular.SerializeOptions]::new()
$script = [Microsoft.AnalysisServices.Tabular.JsonSerializer]::SerializeDatabase($db, $opt)
$script | Out-File $scriptFile
}
$svr.Disconnect()