I'm trying to call Microsoft.AnalysisServices.Tabular.JsonScripter methods within Powershell to automatically generate CreateOrReplace database scripts for SSAS Tabular. However, when I try to execute the following code I receive an error message.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular");
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Core");
$tab = "<Server>";
$dbId = "<Database>";
#$saveas = "C:\temp\{0}.dax" -f $tab.Replace('\', '_');
$as = New-Object Microsoft.AnalysisServices.Tabular.Server;
$as.Connect($tab);
$db = $as.Databases[$dbId];
[Microsoft.AnalysisServices.Tabular.JsonScripter]::ScriptCreateOrReplace($db);
Exception calling "ScriptCreateOrReplace" with "1" argument(s): "Could not load file or assembly 'Microsoft.AnalysisServices.Tabular.Json, Version=17.0.0.0,
Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified."
At line:23 char:9
+ [Microsoft.AnalysisServices.Tabular.JsonScripter]::ScriptCrea ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileNotFoundException
I checked which versions I have installed (referencing this article https://learn.microsoft.com/en-us/bi-reference/tom/install-distribute-and-reference-the-tabular-object-model) and found these versions in my GAC folder.
PS C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.AnalysisServices.Tabular> Get-ChildItem
Directory: C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.AnalysisServices.Tabular
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 20.09.2018 12:45 v4.0_13.0.0.0__89845dcd8080cc91
d----- 11.09.2018 10:06 v4.0_14.0.0.0__89845dcd8080cc91
d----- 01.07.2019 16:38 v4.0_15.0.0.0__89845dcd8080cc91
According to MS documentation, there is no Version 17.0.0.0 and I am confused as to why the method needs this version, which does not exist to my knowledge.
Has anyone encountered a similar error or spots a mistake in my approach?
Sidenote: I am not proficient in neither Powershell nor .net and my understanding of the subject is basic, so please bear with me.
M