<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Powershell : Tabular Object Model, model object is null in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Powershell-Tabular-Object-Model-model-object-is-null/m-p/3261868#M42885</link>
    <description>&lt;P&gt;I sometimes use PowerShell to quickly alter a set of similar measures in a Power BI dataset. This could be done with this code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular")&lt;/P&gt;&lt;P&gt;$serverName = "localhost:xxxxx";&lt;BR /&gt;$databaseName = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";&lt;BR /&gt;$svr = New-Object Microsoft.AnalysisServices.Tabular.Server&lt;BR /&gt;$svr.Connect($serverName)&lt;BR /&gt;$db = $svr.databases.GetByName($databaseName)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$findstring="find string"&lt;BR /&gt;$replacestring="replace string"&lt;/P&gt;&lt;P&gt;foreach($table in $db.Model.Tables) {&lt;BR /&gt;&amp;nbsp; foreach($measureobj in $table.measures) {&lt;BR /&gt;&amp;nbsp; $measureobj.expression=$measureobj.Expression.replace($findstring,$replacestring)&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#$db.Model.SaveChanges()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Works great, until recently I found some reports where the Model-attribute of the database seems to be empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Peter_MTG_0-1685536489428.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/922484i43971762446271A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Peter_MTG_0-1685536489428.png" alt="Peter_MTG_0-1685536489428.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Although it works perfectly fine in PowerBI, I can't find the model anymore in PowerShell. Also Tabular and DAX Studio are working fine with the reports dataset.&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2023 12:36:56 GMT</pubDate>
    <dc:creator>Peter_MTG</dc:creator>
    <dc:date>2023-05-31T12:36:56Z</dc:date>
    <item>
      <title>Powershell : Tabular Object Model, model object is null</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Powershell-Tabular-Object-Model-model-object-is-null/m-p/3261868#M42885</link>
      <description>&lt;P&gt;I sometimes use PowerShell to quickly alter a set of similar measures in a Power BI dataset. This could be done with this code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular")&lt;/P&gt;&lt;P&gt;$serverName = "localhost:xxxxx";&lt;BR /&gt;$databaseName = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";&lt;BR /&gt;$svr = New-Object Microsoft.AnalysisServices.Tabular.Server&lt;BR /&gt;$svr.Connect($serverName)&lt;BR /&gt;$db = $svr.databases.GetByName($databaseName)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$findstring="find string"&lt;BR /&gt;$replacestring="replace string"&lt;/P&gt;&lt;P&gt;foreach($table in $db.Model.Tables) {&lt;BR /&gt;&amp;nbsp; foreach($measureobj in $table.measures) {&lt;BR /&gt;&amp;nbsp; $measureobj.expression=$measureobj.Expression.replace($findstring,$replacestring)&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#$db.Model.SaveChanges()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Works great, until recently I found some reports where the Model-attribute of the database seems to be empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Peter_MTG_0-1685536489428.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/922484i43971762446271A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Peter_MTG_0-1685536489428.png" alt="Peter_MTG_0-1685536489428.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Although it works perfectly fine in PowerBI, I can't find the model anymore in PowerShell. Also Tabular and DAX Studio are working fine with the reports dataset.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 12:36:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Powershell-Tabular-Object-Model-model-object-is-null/m-p/3261868#M42885</guid>
      <dc:creator>Peter_MTG</dc:creator>
      <dc:date>2023-05-31T12:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell : Tabular Object Model, model object is null</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Powershell-Tabular-Object-Model-model-object-is-null/m-p/3263569#M42905</link>
      <description>&lt;P&gt;I saw that in the report one of the datasources was still using the Power BI dataflows (Legacy) connector. As soon as I switched this one to the Power BI dataflows connector, the model attribute was correctly filled in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not 100 % using this connector always causes this problem, but at least in this case, replacing it solved the issue.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 09:37:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Powershell-Tabular-Object-Model-model-object-is-null/m-p/3263569#M42905</guid>
      <dc:creator>Peter_MTG</dc:creator>
      <dc:date>2023-06-01T09:37:53Z</dc:date>
    </item>
  </channel>
</rss>

