<?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 Re: Create partition via powershell error in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Create-partition-via-powershell-error/m-p/3309349#M43301</link>
    <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/551310"&gt;@poweruser1&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Perhaps you can take a look the following sample code if it help with your scenario:&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;$groupID = "&amp;lt;your group ID&amp;gt;"
$datasetID = "&amp;lt;your dataset ID&amp;gt;"
$token = Get-PowerBIAccessToken
$authHeader = @{ "Authorization" = "Bearer $token" }
$uri = "https://api.powerbi.com/v1.0/myorg/groups/$groupID/datasets/$datasetID/Partitions"
$body = @{
    "name" = "ImportName"
    "mode" = "Import"
    "source" = @{
        "type" = "Query"
        "query" = "SELECT * FROM $tableName"
        "dataSource" = @{
            "type" = "Sql"
            "connectionDetails" = @{
				"server" = "$serverName.database.windows.net"
				"database" = "$databaseName"
                "authentication" = "Windows"
            }
        }
    }
}
$jsonBody = $body | ConvertTo-Json
Invoke-RestMethod -Uri $uri -Headers $authHeader -Method Post -Body $jsonBody&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jun 2023 04:24:01 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-06-30T04:24:01Z</dc:date>
    <item>
      <title>Create partition via powershell error</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Create-partition-via-powershell-error/m-p/3306375#M43283</link>
      <description>&lt;P&gt;I am trying to write a Powershell script to create a partition in a Power BI dataset. Anyone know how to resolve this error? I am receiving the following error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="poweruser1_0-1687960687058.png" style="width: 791px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/934712iAA4160C5807554E9/image-dimensions/791x85?v=v2" width="791" height="85" role="button" title="poweruser1_0-1687960687058.png" alt="poweruser1_0-1687960687058.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My Powershell Code:&lt;/P&gt;&lt;P&gt;$m_code = "let&lt;BR /&gt;Source = Sql.Database(`"source`", `"db`", [Query=`"sel column form table`", CommandTimeout=#duration(0, 1, 0, 0)])&lt;BR /&gt;in&lt;BR /&gt;Source"&lt;/P&gt;&lt;P&gt;$tmsl = "{&lt;BR /&gt;`"create`": {&lt;BR /&gt;`"parentObject`": {&lt;BR /&gt;`"database`": `"model name`",&lt;BR /&gt;`"table`": `"Table name`"&lt;BR /&gt;},&lt;BR /&gt;`"partition`": {&lt;BR /&gt;`"name`": `"test partition`",&lt;BR /&gt;`"source`": {&lt;BR /&gt;`"type`": `"m`",&lt;BR /&gt;`"expression`": [&lt;BR /&gt;`"$m_code`"&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}"&lt;/P&gt;&lt;P&gt;invoke-ascmd -Server "powerbi://api.powerbi.com/v1.0/myorg/workspace" -Database "model Name" -Query $tmsl&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 14:02:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Create-partition-via-powershell-error/m-p/3306375#M43283</guid>
      <dc:creator>poweruser1</dc:creator>
      <dc:date>2023-06-28T14:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create partition via powershell error</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Create-partition-via-powershell-error/m-p/3309349#M43301</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/551310"&gt;@poweruser1&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Perhaps you can take a look the following sample code if it help with your scenario:&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;$groupID = "&amp;lt;your group ID&amp;gt;"
$datasetID = "&amp;lt;your dataset ID&amp;gt;"
$token = Get-PowerBIAccessToken
$authHeader = @{ "Authorization" = "Bearer $token" }
$uri = "https://api.powerbi.com/v1.0/myorg/groups/$groupID/datasets/$datasetID/Partitions"
$body = @{
    "name" = "ImportName"
    "mode" = "Import"
    "source" = @{
        "type" = "Query"
        "query" = "SELECT * FROM $tableName"
        "dataSource" = @{
            "type" = "Sql"
            "connectionDetails" = @{
				"server" = "$serverName.database.windows.net"
				"database" = "$databaseName"
                "authentication" = "Windows"
            }
        }
    }
}
$jsonBody = $body | ConvertTo-Json
Invoke-RestMethod -Uri $uri -Headers $authHeader -Method Post -Body $jsonBody&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 04:24:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Create-partition-via-powershell-error/m-p/3309349#M43301</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-30T04:24:01Z</dc:date>
    </item>
  </channel>
</rss>

