web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Running a Powershell S...
Power Automate
Unanswered

Running a Powershell Script in Power Automate

(0) ShareShare
ReportReport
Posted on by 381

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 

Categories:
I have the same question (0)
  • SudeepGhatakNZ Profile Picture
    14,396 Most Valuable Professional on at

    @Vstar19 

    There are several options

    1. To run a PowerShell script with PA, you will need to use Power Automate Desktop

    Solved: Invoke PowerShell script using Power Automate Desk... - Power Platform Community (microsoft.com)

    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

     Embed Power BI content in an embedded analytics application with service principal and an application secret - Power BI | Microsoft Learn

     

  • Vstar19 Profile Picture
    381 on at

    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?

     

  • SudeepGhatakNZ Profile Picture
    14,396 Most Valuable Professional on at

    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"
    }

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard