Forum Discussion

powerapps_tec's avatar
powerapps_tec
Icon for Advocate I rankAdvocate I
1 year ago
Solved

Tenant parameter on Connect-PowerBIServiceAccount for all parametersets

Hello,
It seems like there is still no support for the tenant parameter with Connect-PowerBIServiceAccount for all parametersets.
Here is the context and history of this issue
https://github.com/microsoft/powerbi-powershell/pull/257
https://github.com/microsoft/powerbi-powershell/issues/244
Would it be possible to expedite this? And if not, can you please provide alternative cmdlet(s) to connect to the service with a tenant Id? This is essential for B2B guest admin users to be able to create workspaces.
Many thanks.

 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi powerapps_tec,

     

    Thank you for reaching out to the Microsoft Fabric Forum Community.

     

    If the issue still persists, I’d recommend raising a support ticket with Microsoft. The support team can look into the backend and provide more in depth assistance tailored to your environment.
    https://learn.microsoft.com/en-us/power-bi/support/create-support-ticket

     

    If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.


    Thank you & regards,
    Prasanna Kumar

     

9 Replies

  • powerapps_tec 

    Current reality:

    • You cannot today natively pass -TenantId and guarantee it will behave as expected across all flows.

    • Microsoft sometimes recommends interactive login (ugh, not automation friendly).

    • Some partial workarounds exist using MSAL libraries (manual token fetching) but they are clunky.

      Your Alternatives (today):

      1. Use -Environment switch

      Sometimes specifying -Environment like this can help:
      Connect-PowerBIServiceAccount -Environment "Public"
      But it won’t switch tenant automatically — this mainly impacts cloud environment, not tenant selection.

      2. Manually fetch token using MSAL.PS

      You can manually fetch a token for the right tenant and then connect:

      Install-Module MSAL.PS

      $TenantId = "<TenantId>"
      $ClientId = "04b07795-8ddb-461a-bbee-02f9e1bf7b46" # Public client ID for Microsoft apps
      $Scope = "https://analysis.windows.net/powerbi/api/.default"

      $AuthResult = Get-MsalToken -TenantId $TenantId -ClientId $ClientId -Scopes $Scope -Interactive

      Connect-PowerBIServiceAccount -AccessToken $AuthResult.AccessToken

      Note: You'll still need interactive approval unless you have app registration setups.

      Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!



    • powerapps_tec's avatar
      powerapps_tec
      Icon for Advocate I rankAdvocate I

      Interactive login is not an issue for my use case, in fact it is preferable. However, Connect-PowerBIServiceAccount does not support an AccessToken parameter. Could you please review and let me know which parameter you are trying to set?
      Many thanks.

  • powerapps_tec 

    I am assuming your are using User principal name while running Connect-PowerBIServiceAccount cmdlet, have you tried using service principal authentication instead ? that way you can pass the tenant id as well. 

     

    Connect-PowerBIServiceAccount -Tenant [TenantId] -ServicePrincipal -Credential (Get-Credential)

     

    You can store your credentails in a secure azure key vault and access it from the power shell code and run your scripts. Incase if this does not serve your purpose then I would suggest you to raise this idea in ideas forum 

    https://community.fabric.microsoft.com/t5/Fabric-Ideas/idb-p/fbc_ideas

    Need a Power BI Consultation? Hire me on Upwork

     

     

     

    Connect on LinkedIn

     

     

     








    Did I answer your question? Mark my post as a solution!
    If I helped you, click on the Thumbs Up to give Kudos.

    Proud to be a Super User!


     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi powerapps_tec,

     

    Just following up to check if the solution shared by our Super User helped resolve your issue. If you're still facing difficulties or need further assistance, please let us know — we’re here to help!

    If the response addressed your query, we kindly request you to mark it as Accepted Solution and click Yes if you found it helpful. This supports others in the community as well.

     

    Best regards,

    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi powerapps_tec ,

     

    We wanted to kindly check in to see if everything is working as expected after trying the suggested solution. If there’s anything else we can assist with, please don’t hesitate to ask.

    If the issue is resolved, we’d appreciate it if you could mark the helpful reply as Accepted Solution — it helps others who might face a similar issue.

     

    Warm regards,

    Prasanna Kumar

    • powerapps_tec's avatar
      powerapps_tec
      Icon for Advocate I rankAdvocate I

      Hello Prasanna,
      As I mentioned in my reply to johnbasha33, the Connect-PowerBIServiceAccount does not support an AccessToken parameter, so the suggested form of the cmdlet does not work.
      Service Principal is not an option either because I need the specific user (interactively) to be able to take ownership of all the objects created. Taking ownership after the objects have been created has other problems that prevent the correct flow of my application. 

      I hope this response answers your question. Many thanks for following up. 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi powerapps_tec,

         

        Thank you for reaching out to the Microsoft Fabric Forum Community.

         

        If the issue still persists, I’d recommend raising a support ticket with Microsoft. The support team can look into the backend and provide more in depth assistance tailored to your environment.
        https://learn.microsoft.com/en-us/power-bi/support/create-support-ticket

         

        If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.


        Thank you & regards,
        Prasanna Kumar

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi powerapps_tec,

     

    I hope you're doing well. Since you've mentioned that a Idea ticket has been raised, it would be greatly appreciated if you could mark that reply as the accepted solution. This will help other community members quickly find relevant answers.

     

    Warm regards,
    Prasanna Kumar