<?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 Adding AD Group to a workspace via API in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Adding-AD-Group-to-a-workspace-via-API/m-p/3094545#M41399</link>
    <description>&lt;P&gt;I am trying to manage access to workspaces via API and AD (or AAD) Groups. I have a service principal with&amp;nbsp;&lt;SPAN&gt;Tenant.ReadWrite.All permission granted&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BoNDoK00_0-1677129103014.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/876443iF9E40F6F545075BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BoNDoK00_0-1677129103014.png" alt="BoNDoK00_0-1677129103014.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The service principal is &lt;U&gt;&lt;STRONG&gt;not&lt;/STRONG&gt;&lt;/U&gt; added to the workspace I try to modify.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I tried with no success:&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Using PBI Cmdlets&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1. Login to PBI Service using a service principal&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$clientId = "XXX"
$tenantId =  "XXX"
$clientSecret =  "XXX"
$SecurePassword = ConvertTo-SecureString $clientSecret -Force -AsPlainText
$servicePrincipal = New-Object -TypeName PSCredential ($clientId, $SecurePassword)
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $servicePrincipal -Environment Public -Tenant $tenantId&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Use Cmdlets to add a group to a workspace&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Add-PowerBIGroupUser  -Scope Individual -AccessRight Admin -PrincipalType Group -Id &amp;lt;WorkspaceID&amp;gt;  -Identifier &amp;lt;AD Group Object ID&amp;gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;3. I receive this error:&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Add-PowerBIGroupUser : Operation returned an invalid status code 'NotFound'
At line:1 char:1
+ Add-PowerBIGroupUser  -Scope Individual -AccessRight Admin -Principal ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...BIWorkspaceUser:AddPowerBIWorkspaceUser) [Add-PowerBIWorkspaceUser], HttpOperationException
    + FullyQualifiedErrorId : Operation returned an invalid status code 'NotFound',Microsoft.PowerBI.Commands.Workspaces.AddPowerBIWorkspaceUser&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;4. I add the service principal to the workspace as an admin, then remove it 5 seocnds later, and I do the same call as in step 2, it works!&lt;/P&gt;&lt;P&gt;Any idea why?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Feb 2023 05:18:15 GMT</pubDate>
    <dc:creator>BoNDoK00</dc:creator>
    <dc:date>2023-02-23T05:18:15Z</dc:date>
    <item>
      <title>Adding AD Group to a workspace via API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Adding-AD-Group-to-a-workspace-via-API/m-p/3094545#M41399</link>
      <description>&lt;P&gt;I am trying to manage access to workspaces via API and AD (or AAD) Groups. I have a service principal with&amp;nbsp;&lt;SPAN&gt;Tenant.ReadWrite.All permission granted&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BoNDoK00_0-1677129103014.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/876443iF9E40F6F545075BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BoNDoK00_0-1677129103014.png" alt="BoNDoK00_0-1677129103014.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The service principal is &lt;U&gt;&lt;STRONG&gt;not&lt;/STRONG&gt;&lt;/U&gt; added to the workspace I try to modify.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I tried with no success:&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Using PBI Cmdlets&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1. Login to PBI Service using a service principal&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$clientId = "XXX"
$tenantId =  "XXX"
$clientSecret =  "XXX"
$SecurePassword = ConvertTo-SecureString $clientSecret -Force -AsPlainText
$servicePrincipal = New-Object -TypeName PSCredential ($clientId, $SecurePassword)
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $servicePrincipal -Environment Public -Tenant $tenantId&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Use Cmdlets to add a group to a workspace&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Add-PowerBIGroupUser  -Scope Individual -AccessRight Admin -PrincipalType Group -Id &amp;lt;WorkspaceID&amp;gt;  -Identifier &amp;lt;AD Group Object ID&amp;gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;3. I receive this error:&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Add-PowerBIGroupUser : Operation returned an invalid status code 'NotFound'
At line:1 char:1
+ Add-PowerBIGroupUser  -Scope Individual -AccessRight Admin -Principal ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...BIWorkspaceUser:AddPowerBIWorkspaceUser) [Add-PowerBIWorkspaceUser], HttpOperationException
    + FullyQualifiedErrorId : Operation returned an invalid status code 'NotFound',Microsoft.PowerBI.Commands.Workspaces.AddPowerBIWorkspaceUser&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;4. I add the service principal to the workspace as an admin, then remove it 5 seocnds later, and I do the same call as in step 2, it works!&lt;/P&gt;&lt;P&gt;Any idea why?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 05:18:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Adding-AD-Group-to-a-workspace-via-API/m-p/3094545#M41399</guid>
      <dc:creator>BoNDoK00</dc:creator>
      <dc:date>2023-02-23T05:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Adding AD Group to a workspace via API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Adding-AD-Group-to-a-workspace-via-API/m-p/3102741#M41453</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/479142"&gt;@BoNDoK00&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Have you re-input the credentials for other API usages? AFAIK, when you work with 'Service Principal' mode, the credential seems only work for the current API and not been kept to quick verify other API. You need to manually input credentials before API usages every time.&lt;/FONT&gt;&lt;/P&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>Tue, 28 Feb 2023 02:41:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Adding-AD-Group-to-a-workspace-via-API/m-p/3102741#M41453</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-28T02:41:42Z</dc:date>
    </item>
  </channel>
</rss>

