Hello.
I have a Powershell script which i run daily.
In its simplest form, its just grabbing a whole bunch of power bi workspaces and outputting the data into a .csv file.
I want to automate this process.
I tried using Task Scheduler, however, the problem here is when i run the Powershell script i am using the Connect-PowerBIServiceAccount & then authenticating with the admin account (as this account has access to retrieve all the workspaces). With task scheudler, i dont know how to run the script without storing the service account password in the script.
1. Can i automate this process in Power Automate? - i cant see a Powershell connector.
2. Or can someone tell me how i can run this as a Task Schedule without storing the admin account in the ps1 script.
Thanks
Even if you use Power Automate Desktop, you should store the creds in Azure Vault or Windows Credential Manager.
The Power Sheel script will go something like this
Install-Module -Name 'PSCredentialManager' -Force
# Import the PSCredentialManager module
Import-Module -Name 'PSCredentialManager'
# Define the target name of the credential
$targetName = "example.com"
# Retrieve the stored credential
$credential = Get-StoredCredential -Target $targetName
if ($credential -ne $null) {
Write-Host "Username: $($credential.UserName)"
Write-Host "Password: $($credential.GetNetworkCredential().Password)"
} else {
Write-Host "No credential found for target: $targetName"
}
Storing in windows credential manager seems like a good solution. I will read more into this.
If i was to use Power Automate Desktop to run a ps.1 file - would i still have to supply the credentials to PA Desktop?
There are several options
1. To run a PowerShell script with PA, you will need to use Power Automate Desktop
2. You can also use the cloud flow along with Azure Automation
Getting started with Azure Automation and Power Automate (youtube.com)
3. Instead of storing the credentials in script, use the Windows Credential Manager to store your credentials and retrieve them within the script
# Retrieve credentials from Windows Credential Manager
$credential = Get-Credential -UserName "PowerBIAutomation" -Message "Enter PowerBI Admin Credentials"
# Connect to Power BI Service
Connect-PowerBIServiceAccount -Credential $credential
4. Use a Service principal instead of Service Account
WarrenBelz
146,776
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,093
Most Valuable Professional