<?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 Service Principle cannot Get-PowerBIWorkspace in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Service-Principle-cannot-Get-PowerBIWorkspace/m-p/2315614#M34180</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to use the Power BI Rest API via Powershell authenticating with my service principle to retrieve a workspaceid for a given named workspace via "Get-PowerBIWorkspace", unfortunately I receive "Get-PowerBIWorkspace : Operation returned an invalid status code 'Unauthorized'"?? Do service principles not have access to this API? I can access via "&lt;SPAN&gt;Login-PowerBIServiceAccount" authenticating with my Power BI Admin account so I guess not. How can I re-write the below for the APIs a service principle can access?...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;$WorkspaceName&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&amp;nbsp;"Test Workspace"&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;#Get PBI workspace attributes&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;$Workspace&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;Get-PowerBIWorkspace&lt;/SPAN&gt; &lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;Scope Organization &lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;Name &lt;/SPAN&gt;&lt;SPAN&gt;$WorkspaceName&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;$WorkspaceId&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;$Workspace.Id&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Write-Host&lt;/SPAN&gt; &lt;SPAN&gt;"Workspace ID: "&lt;/SPAN&gt;&lt;SPAN&gt;$WorkspaceId&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 02 Feb 2022 15:17:06 GMT</pubDate>
    <dc:creator>powerbi_jenhen</dc:creator>
    <dc:date>2022-02-02T15:17:06Z</dc:date>
    <item>
      <title>Service Principle cannot Get-PowerBIWorkspace</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Service-Principle-cannot-Get-PowerBIWorkspace/m-p/2315614#M34180</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to use the Power BI Rest API via Powershell authenticating with my service principle to retrieve a workspaceid for a given named workspace via "Get-PowerBIWorkspace", unfortunately I receive "Get-PowerBIWorkspace : Operation returned an invalid status code 'Unauthorized'"?? Do service principles not have access to this API? I can access via "&lt;SPAN&gt;Login-PowerBIServiceAccount" authenticating with my Power BI Admin account so I guess not. How can I re-write the below for the APIs a service principle can access?...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;$WorkspaceName&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&amp;nbsp;"Test Workspace"&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;#Get PBI workspace attributes&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;$Workspace&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;Get-PowerBIWorkspace&lt;/SPAN&gt; &lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;Scope Organization &lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;Name &lt;/SPAN&gt;&lt;SPAN&gt;$WorkspaceName&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;$WorkspaceId&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;$Workspace.Id&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Write-Host&lt;/SPAN&gt; &lt;SPAN&gt;"Workspace ID: "&lt;/SPAN&gt;&lt;SPAN&gt;$WorkspaceId&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 02 Feb 2022 15:17:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Service-Principle-cannot-Get-PowerBIWorkspace/m-p/2315614#M34180</guid>
      <dc:creator>powerbi_jenhen</dc:creator>
      <dc:date>2022-02-02T15:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Service Principle cannot Get-PowerBIWorkspace</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Service-Principle-cannot-Get-PowerBIWorkspace/m-p/2315750#M34181</link>
      <description>&lt;P&gt;Fixed this by removing "&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;Scope Organization"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;That was surprisingly easy &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 16:27:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Service-Principle-cannot-Get-PowerBIWorkspace/m-p/2315750#M34181</guid>
      <dc:creator>powerbi_jenhen</dc:creator>
      <dc:date>2022-02-02T16:27:23Z</dc:date>
    </item>
  </channel>
</rss>

