<?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: PowerShell Rest API /RefreshSchedule Patch doesn't work in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/PowerShell-Rest-API-RefreshSchedule-Patch-doesn-t-work/m-p/1879287#M29756</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/106469"&gt;@zuheirashraf17&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have&amp;nbsp;&lt;SPAN&gt;permissions for read and write?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My understanding is that in order for the API to work it actually has to write&amp;nbsp;permissions with the dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Before you run this command, make sure you log in using Connect-PowerBIServiceAccount.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Liang &lt;BR /&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jun 2021 06:06:34 GMT</pubDate>
    <dc:creator>V-lianl-msft</dc:creator>
    <dc:date>2021-06-03T06:06:34Z</dc:date>
    <item>
      <title>PowerShell Rest API /RefreshSchedule Patch doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerShell-Rest-API-RefreshSchedule-Patch-doesn-t-work/m-p/1873989#M29703</link>
      <description>&lt;P&gt;Hello experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm fairly new to working with API. I've been trying this out without success and in need of assistance to see what went wrong and how could I fix it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Powershell with Service Principle account is being used to perform this task, I believe all needed permission has been granted via Azure Active Directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Process&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Take Over Dataset - Success (Dataset was successfully taken over by the Service principle account)&lt;/LI&gt;&lt;LI&gt;Disable Refresh Schedule - Fail (This is where the error shows up)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;STRONG&gt;Script of the PowerShell&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$Workspacename = xxx
$Datasetname   = xxx
$ClientID      = xxx
$ClientSecret  = xxx
$TenantID      = xxx

$applicationId = $ClientID # Need to pass the clientid from devops variable 
$clientsec = $ClientSecret | ConvertTo-SecureString -AsPlainText -Force # Need to pass from devops secret variable 
 
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $clientsec 

#Install-Module -Name MicrosoftPowerBIMgmt.Profile -Verbose -Scope CurrentUser -Force
#Install-Module -Name MicrosoftPowerBIMgmt.Workspaces -Verbose -Scope CurrentUser -Force
$Connect = Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -Environment Public -Tenant $TenantID


$workspace = Get-PowerBIWorkspace -Name $Workspacename

$DatasetResponse=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets" -Method Get | ConvertFrom-Json

$datasets = $DatasetResponse.value

     foreach($dataset in $datasets){
                if($dataset.name -eq $Datasetname){
                $datasetid= $dataset.id;
                break;
                }

            }

 Invoke-PowerBIRestMethod -URL "groups/$($Workspace.id)/datasets/$($Dataset.id)/Default.TakeOver" -Method Post
 
 $DisableScriptJson = @{
   value= @{
     enabled= "false"
   }
 } | ConvertTo-Json

Invoke-PowerBIRestMethod -URL "groups/$($Workspace.id)/datasets/$($Dataset.id)/refreshSchedule" -METHOD Patch -Body $DisableScriptJson | ConvertFrom-Json&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Invoke-PowerBIRestMethod : One or more errors occurred.
At line:42 char:2
+  Invoke-PowerBIRestMethod -URL "groups/$($Workspace.id)/datasets/$($D ...
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
    + FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated, let me know if further information is needed&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 02:55:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerShell-Rest-API-RefreshSchedule-Patch-doesn-t-work/m-p/1873989#M29703</guid>
      <dc:creator>zuheirashraf17</dc:creator>
      <dc:date>2021-06-01T02:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell Rest API /RefreshSchedule Patch doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerShell-Rest-API-RefreshSchedule-Patch-doesn-t-work/m-p/1879287#M29756</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/106469"&gt;@zuheirashraf17&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have&amp;nbsp;&lt;SPAN&gt;permissions for read and write?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My understanding is that in order for the API to work it actually has to write&amp;nbsp;permissions with the dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Before you run this command, make sure you log in using Connect-PowerBIServiceAccount.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Liang &lt;BR /&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 06:06:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerShell-Rest-API-RefreshSchedule-Patch-doesn-t-work/m-p/1879287#M29756</guid>
      <dc:creator>V-lianl-msft</dc:creator>
      <dc:date>2021-06-03T06:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell Rest API /RefreshSchedule Patch doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerShell-Rest-API-RefreshSchedule-Patch-doesn-t-work/m-p/1879328#M29758</link>
      <description>&lt;P&gt;Hello Liang/&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/182446"&gt;@V-lianl-msft&lt;/a&gt;&amp;nbsp;, appreciate your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for the permission, I believe this should be enough right?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="zuheirashraf17_0-1622701010800.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/526690i4CDACA754E4D5EBA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="zuheirashraf17_0-1622701010800.png" alt="zuheirashraf17_0-1622701010800.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for&amp;nbsp;&lt;SPAN&gt;Connect-PowerBIServiceAccount, it was able to connect just fine, please see my script. And the service account has admin access to the workspace too. In fact it was able to take over the dataset, but fail when trying to update/disable the refresh schedule.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 06:39:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerShell-Rest-API-RefreshSchedule-Patch-doesn-t-work/m-p/1879328#M29758</guid>
      <dc:creator>zuheirashraf17</dc:creator>
      <dc:date>2021-06-03T06:39:16Z</dc:date>
    </item>
  </channel>
</rss>

