<?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 Help with Editing Data Source Credentials in PowerShell for Power BI Embedded Dashboards in D365 CRM in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Help-with-Editing-Data-Source-Credentials-in-PowerShell-for/m-p/4362687#M59004</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;We are currently migrating Power BI embedded dashboards from one Dynamics 365 CRM tenant to another. The process involves creating a new Power BI report within a workspace. Since the Dynamics 365 Solution does not support the inclusion of Power BI reports within unmanaged solutions, we have resorted to using PowerShell scripting to manage the migration.&lt;/P&gt;
&lt;P&gt;During this migration, we encountered an issue where the report IDs from the original environment remained linked when moving the Power BI embedded dashboards to the new environment. To address this, we have utilized Environment Variables to map the new report and workspace IDs appropriately.&lt;/P&gt;
&lt;P&gt;However, we are facing an issue when attempting to edit the Data Source Credentials using PowerShell scripting. Specifically, we are receiving a "Bad Request" error, as shown in the screenshot below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SamInogic_0-1736838004550.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1225718iA616B3EAA8C560BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SamInogic_0-1736838004550.jpeg" alt="SamInogic_0-1736838004550.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the PowerShell code we are currently using to edit the Data Source Credentials:&lt;/P&gt;
&lt;P&gt;Connect-PowerBIServiceAccount&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$accesstoken = Get-PowerBIAccessToken&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$patchBody = '"credentialDetails": {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; "credentials": {"accessToken":"'+$($accesstoken)+'"},&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "encryptedConnection": "Encrypted",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; "encryptionAlgorithm": "None",&lt;/P&gt;
&lt;P&gt;&amp;nbsp; "privacyLevel": "Organizational",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "useEndUserOAuth2Credentials": true&lt;/P&gt;
&lt;P&gt;}'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Invoke-PowerBIRestMethod -Url "&lt;A href="https://api.powerbi.com/v1.0/myorg/gateways/9eaed562-e9c2-46e4-91cf-276ed0947b41/datasources/f1181856-de29-4a9a-a555-a0e181cd7898" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/gateways/9eaed562-e9c2-46e4-91cf-276ed0947b41/datasources/f1181856-de29-4a9a-a555-a0e181cd7898&lt;/A&gt;" -Method Patch -Body $patchBody&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would greatly appreciate any guidance or suggestions on resolving this error in the PowerShell scripting process for updating the Data Source Credentials.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jan 2025 07:03:31 GMT</pubDate>
    <dc:creator>SamInogic</dc:creator>
    <dc:date>2025-01-14T07:03:31Z</dc:date>
    <item>
      <title>Help with Editing Data Source Credentials in PowerShell for Power BI Embedded Dashboards in D365 CRM</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Help-with-Editing-Data-Source-Credentials-in-PowerShell-for/m-p/4362687#M59004</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;We are currently migrating Power BI embedded dashboards from one Dynamics 365 CRM tenant to another. The process involves creating a new Power BI report within a workspace. Since the Dynamics 365 Solution does not support the inclusion of Power BI reports within unmanaged solutions, we have resorted to using PowerShell scripting to manage the migration.&lt;/P&gt;
&lt;P&gt;During this migration, we encountered an issue where the report IDs from the original environment remained linked when moving the Power BI embedded dashboards to the new environment. To address this, we have utilized Environment Variables to map the new report and workspace IDs appropriately.&lt;/P&gt;
&lt;P&gt;However, we are facing an issue when attempting to edit the Data Source Credentials using PowerShell scripting. Specifically, we are receiving a "Bad Request" error, as shown in the screenshot below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SamInogic_0-1736838004550.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1225718iA616B3EAA8C560BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SamInogic_0-1736838004550.jpeg" alt="SamInogic_0-1736838004550.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the PowerShell code we are currently using to edit the Data Source Credentials:&lt;/P&gt;
&lt;P&gt;Connect-PowerBIServiceAccount&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$accesstoken = Get-PowerBIAccessToken&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$patchBody = '"credentialDetails": {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; "credentials": {"accessToken":"'+$($accesstoken)+'"},&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "encryptedConnection": "Encrypted",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; "encryptionAlgorithm": "None",&lt;/P&gt;
&lt;P&gt;&amp;nbsp; "privacyLevel": "Organizational",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "useEndUserOAuth2Credentials": true&lt;/P&gt;
&lt;P&gt;}'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Invoke-PowerBIRestMethod -Url "&lt;A href="https://api.powerbi.com/v1.0/myorg/gateways/9eaed562-e9c2-46e4-91cf-276ed0947b41/datasources/f1181856-de29-4a9a-a555-a0e181cd7898" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/gateways/9eaed562-e9c2-46e4-91cf-276ed0947b41/datasources/f1181856-de29-4a9a-a555-a0e181cd7898&lt;/A&gt;" -Method Patch -Body $patchBody&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would greatly appreciate any guidance or suggestions on resolving this error in the PowerShell scripting process for updating the Data Source Credentials.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 07:03:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Help-with-Editing-Data-Source-Credentials-in-PowerShell-for/m-p/4362687#M59004</guid>
      <dc:creator>SamInogic</dc:creator>
      <dc:date>2025-01-14T07:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Editing Data Source Credentials in PowerShell for Power BI Embedded Dashboards in D365</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Help-with-Editing-Data-Source-Credentials-in-PowerShell-for/m-p/4363558#M59009</link>
      <description>&lt;P&gt;That's patching the credentials for the gateway connection, not for the semantic model?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 15:21:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Help-with-Editing-Data-Source-Credentials-in-PowerShell-for/m-p/4363558#M59009</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2025-01-14T15:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Editing Data Source Credentials in PowerShell for Power BI Embedded Dashboards in D365</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Help-with-Editing-Data-Source-Credentials-in-PowerShell-for/m-p/4364762#M59015</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/480849"&gt;@SamInogic&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Could you please provide the following info for the further troubleshooting?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt;&lt;SPAN&gt;Whether the access token &lt;EM&gt;$accesstoken&lt;/EM&gt; is being retrieved correctly and is valid?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;SPAN&gt;Whether the gateway and data source IDs used in the endpoint URL are correct and accessible within the new tenant?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Whether the account you are using has the necessary permissions for updating data source credential?&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;
&lt;P&gt;&lt;EM&gt;# Connect to the Power BI Service&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Connect-PowerBIServiceAccount&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;# Get Access Token&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$accesstoken = Get-PowerBIAccessToken&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;# Construct the request body&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$patchBody = @{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"credentialDetails" = @{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"credentials" = @{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"accessToken" = $accesstoken&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"encryptedConnection" = "Encrypted"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"encryptionAlgorithm" = "None"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"privacyLevel" = "Organizational"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"useEndUserOAuth2Credentials" = $true&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;# Convert the request body to JSON&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$jsonBody = $patchBody | ConvertTo-Json -Depth 10&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;# API Endpoint (replace with your specific gateway and data source ID)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$apiUrl = "&lt;A href="https://api.powerbi.com/v1.0/myorg/gateways/9eaed562-e9c2-46e4-91cf-276ed0947b41/datasources/f118185" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/gateways/9eaed562-e9c2-46e4-91cf-276ed0947b41/datasources/f118185&lt;/A&gt;..."&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;# Send the PATCH request&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Invoke-PowerBIRestMethod -Url $apiUrl -Method Patch -Body $jsonBody -ContentType "application/json"&lt;/EM&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 09:32:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Help-with-Editing-Data-Source-Credentials-in-PowerShell-for/m-p/4364762#M59015</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-15T09:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Editing Data Source Credentials in PowerShell for Power BI Embedded Dashboards in D365</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Help-with-Editing-Data-Source-Credentials-in-PowerShell-for/m-p/4369163#M59116</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for all your help and suggestions. After trying the different recommendations, we followed these steps, and it resolved the issue:&lt;/P&gt;
&lt;P&gt;$body = @{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "credentialDetails" = @{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "credentialType"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = "OAuth2"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "encryptedConnection"&amp;nbsp;&amp;nbsp;&amp;nbsp; = "Encrypted"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "encryptionAlgorithm"&amp;nbsp;&amp;nbsp;&amp;nbsp; = "None"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "privacyLevel"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = "Organizational"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "useCallerAADIdentity"&amp;nbsp;&amp;nbsp; = $true&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;# Convert the body to JSON format&lt;/P&gt;
&lt;P&gt;$jsonBody = $body | ConvertTo-Json -Depth 5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Invoke-PowerBIRestMethod -Url "&lt;A href="https://api.powerbi.com/v1.0/myorg/gateways/$($datasource.GatewayId)/datasources/$($datasource.DatasourceId)" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/gateways/$($datasource.GatewayId)/datasources/$($datasource.DatasourceId)&lt;/A&gt;" -Method PATCH -Body $jsonBody&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate the time you all took to assist me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 12:41:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Help-with-Editing-Data-Source-Credentials-in-PowerShell-for/m-p/4369163#M59116</guid>
      <dc:creator>SamInogic</dc:creator>
      <dc:date>2025-01-17T12:41:15Z</dc:date>
    </item>
  </channel>
</rss>

