Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello,
I am trying to login to PowerBI using Power Shell. If I just use Connect-PowerBIServiceAccount by itself, it pops open the login dialog and then carries on properly.
But if I try to embed the password, it gives me an error:
Code:
$password = "thepassword" | ConvertTo-SecureString -asPlainText -Force
$username = "user@domain.com"
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
Connect-PowerBIServiceAccount -Credential $credential
Resolve-PowerBIError -Last
Message : Error Acquiring Token:
AADSTS50126: Error validating credentials due to invalid username or password.
(The less helpful message given by the login attempt is shown below, so to make the question easier to read.)
I have been Googling around and trying random suggestions, but I cannot seem to figure out what is preventing the error. I have, of course, convinced myself that the username and password are actually entered correctly.
Thanks
Stephen
The first part of the message the command gives is as follows:
Connect-PowerBIServiceAccount : One or more errors occurred.
At C:\....\PowerShell\Clear.ps1:21 char:2
+ Connect-PowerBIServiceAccount -Credential $credential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...IServiceAccount:ConnectPowerBIServiceAccount) [Connect-PowerBIServiceAccount], Aggr
egateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.ConnectPowerBIServiceAccount
WARNING: (False) MSAL 4.25.0.0 MSAL.Desktop Microsoft Windows NT 10.0.19044.0 [06/20/2022 19:44:14 - f3fe14c0-a2f2-486a-82b6-f0ab1d92bd9c] Request
retry failed.
WARNING: (False) MSAL 4.25.0.0 MSAL.Desktop Microsoft Windows NT 10.0.19044.0 [06/20/2022 19:44:14 - f3fe14c0-a2f2-486a-82b6-f0ab1d92bd9c] Excepti
on type: Microsoft.Identity.Client.MsalUiRequiredException
, ErrorCode: invalid_grant
HTTP StatusCode 400
CorrelationId f3fe14c0-a2f2-486a-82b6-f0ab1d92bd9c
Hi @PowerBI-ELM
Do you have MFA enabled on your account?
Looking at your code it is what I have and it certainly works for me.
Also just to confirm you have got the latest version of the PowerBI PowerShell Modules installed?
I should have the most recent API as just set it up recently. Also, just in case I tried an update.
I do not have MFA installed.
So still stuck ...
Hi @PowerBI-ELM
Yeah the only other thing would be to chat to your Azure/Network Admin to make sure that they allow the account to log in via the PowerShell commands?
my login (email) is a powerbi admin and a global admin. Is there anything else?
Hi @PowerBI-ELM
Ahh wait can you make sure where you are running PowerShell that you have TLS 1.2 enabled?
If not put this at the start of the PowerShell Script
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
86 | |
46 | |
25 | |
21 | |
19 |