Connect to powerbi service without prompting for entering credentials

Gayatri Khatale 0 Reputation points
2023-06-01T05:35:07.04+00:00

Hi, My name is Gayatri. I am working as a Intern. I want your help. I am trying to run script in powershell for connecting to powerbi service without prompting for entering credentials. But its not working properly giving so much error. Can you please help me. How should I do this?

Code:

Import-Module MicrosoftPowerBIMgmt

Import-Module MicrosoftPowerBIMgmt.Profile

$password = 'abcde' | ConvertTo-SecureString -asPlainText -Force

$username = 'dhh@gn.com'

$credential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username, $password

Connect-PowerBIServiceAccount -Credential $credential

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,448 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,289 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,096 Reputation points
    2023-06-02T15:13:33.9933333+00:00

    Hello

    Thank you for your question and reaching out.

    Please use below code if it works for you , also please Disable MFA for this user.


    #Variables

    $PbiUser1 = "myUser@ mydomain.com"

    $PbiPassword1 = "MyPassword"

    #Create secure string for password

    $PbiSecurePassword = ConvertTo-SecureString $PbiPassword -Force -AsPlainText

    $PbiCredential = New-Object Management.Automation.PSCredential($PbiUser, $PbiSecurePassword)

    #Connect to the Power BI service

    Connect-PowerBIServiceAccount -Credential $PbiCredential


    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments