Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I need to connect POWER BI account without prompting and password would be secure not in script file .
Below is the powershell script :
Clear-Host
$PSScriptRoot= "D:\powershell"
$pathFile = $PSScriptRoot + "\logs\"
$pwdpath = $PSScriptRoot + "\pwd\"
$pwdfile = $pwdpath + "creds.xml"
<# Get password from file, if file exists. Else, create folder and export params after prompted to user. #>
if(Get-Module -Name MicrosoftPowerBIMgmt -ListAvailable){
#Update-Module MicrosoftPowerBIMgmt -Force
}else{
Install-Module MicrosoftPowerBIMgmt -Scope CurrentUser -Force
}
if([System.IO.File]::Exists($pwdfile)){
$mycreds = Import-CliXml -Path $pwdfile
} else {
if(!([System.IO.File]::Exists($pwdpath))){
New-Item -Path $PSScriptRoot -Name "pwd" -ItemType Directory
}
Get-Credential | Export-CliXml -Path $pwdfile
$mycreds = Import-CliXml -Path $pwdfile
}
Connect-PowerBIServiceAccount -Credential $mycreds
It throws an error :
Connect-PowerBIServiceAccount : One or more errors occurred.
At line:25 char:1
+ Connect-PowerBIServiceAccount -Credential $mycreds
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...IServiceAccount:ConnectPowerBIServiceAccount) [
Connect-PowerBIServiceAccount], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.ConnectPowerBI
ServiceAccount
WARNING: (False) MSAL 4.25.0.0 MSAL.Desktop Microsoft Windows NT 10.0.18363.0 [07/13/2021 05:00:52 - c63c9973-
daa8-46e8-be4a-3d848c33c03c] Request retry failed.
WARNING: (False) MSAL 4.25.0.0 MSAL.Desktop Microsoft Windows NT 10.0.18363.0 [07/13/2021 05:00:52 - c63c9973-
daa8-46e8-be4a-3d848c33c03c] Exception type: Microsoft.Identity.Client.MsalClientException
, ErrorCode: user_realm_discovery_failed
at Microsoft.Identity.Client.WsTrust.CommonNonInteractiveHandler.<QueryUserRealmDataAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.UsernamePasswordRequest.<FetchAssertionFromWsTrustAsync>d__4
.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.UsernamePasswordRequest.<ExecuteAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotificatio
Hi @Anonymous
I cannot restore your issue .But I found a similar issue in Forums for you ,maybe you can refer to it .
https://community.powerbi.com/t5/Service/PowerShell-Login-to-Power-BI-Write-Error/m-p/1094922
Best Regards
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 56 | |
| 56 | |
| 35 | |
| 18 | |
| 14 |