title: Powershell - automated connection to Power BI service without hardcoding password
body: <p>We have a PowerShell script to pull Power BI activity data (using Get-PowerBIActivityEvent), and I have been trying to automate it so that it can pull this data daily using an unattended account. The problem is the script must necessarily use the Connect-PowerBIServiceAccount cmdlet, which requires a credential. I don't want to have the passwords hard-coded anywhere (obviously) and ideally don't want to be passing it into the script as a plaintext parameter in case of memory leaks.</p>
  
  <p>I've tried using SSIS as a scheduling mechanism since it allows for encrypted parameters in script tasks, but can't call the PS script with a SecureString parameter since the System.Management.Automation namespace isn't in the GAC (a commandline call wouldn't be possible). 
  I don't believe task scheduler would offer the functionality needed.</p>
  
  <p>Does anyone know of any elegant ways to connect to the power BI service using encrypted credentials?</p>