Azure-Samples / powerbi-powershell

Samples for calling the Power BI REST API via PowerShell
MIT License
258 stars 191 forks source link

User and Password required #19

Open miguel-salles-bisolutions opened 6 years ago

miguel-salles-bisolutions commented 6 years ago

Hi, I am using the manageRefresh.ps1, it works if I type user and password on the pop-up. However, for running after the ETL, I would need it to run unattended.

How do I add user and password for unattended execution to the script?

I understand that like all requests to the Power BI REST API, I will have to attach an AAD access token. But I dont know how to and the Power BI REST API authentication documentation is not something I am familiar with. (https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token)

Thanks

sgsshankar commented 5 years ago

You can use something like this to get the Credentials from Username / Password

$User = " Fill in your Username " $password = " Fill in your Password " $PWord = ConvertTo-SecureString -String $password -AsPlainText -Force $UserCredential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PWord