Forum Discussion
Connecting PowerBI from Power Shell without prompting
If you haven't already, you'll need need to install that certificate at either the user level or machine level on the machine that's running that powershell script. My AD guy created a PFX export of the certificate and that was installed on the server that's running my script. I can't speak to how the export was created (that's certainly not my domain) but maybe you do.
I was able to login successfully without popup using the below command. For credentials, I used appid and secret as username and password.
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $Creds -Tenant $TenantId
But now, I am having issues retrieving the workspace I need. I am trying to retrive my workspace using workspace id. But I am getting unauthorized error. Does the user I am using should be admin?
Get-PowerBIWorkspace -Id xxxxxxxxxx
Error:
Get-PowerBIWorkspace : Operation returned an invalid status code 'Unauthorized'
At line:1 char:1
+ Get-PowerBIWorkspace -Id xxxxxxxxxxxxx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...owerBIWorkspace:GetPowerBIWorkspace) [Get-PowerBIWorkspace], HttpOperationException
+ FullyQualifiedErrorId : Operation returned an invalid status code 'Unauthorized',Microsoft.PowerBI.Commands.Workspaces.GetPowerBIWorkspace
- Anonymous4 years agoNot applicable
If you haven't already, you'll need to add that app registration to an AD security group. Then, you'll need to add that security group in the Power BI Admin Portal under the Admin API settings.
- kranthi_sunkara4 years agoRegular Visitor
It was added already.
When adding a service prinicipal to the workspace, does it require admin permissions?
- Anonymous4 years agoNot applicable
If you're referring to Admin API permissions thorugh the App regisration then no. Don't add any API permissions. Microsoft specifically calls this out in one of their articles.
- kranthi_sunkara4 years agoRegular Visitor
All good now. Everything working for me. Thanks for your help.
- Anonymous4 years agoNot applicable
Good to hear. Happy to help.