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

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to run powershell ...
Power Apps
Unanswered

How to run powershell from a powerapp

(0) ShareShare
ReportReport
Posted on by 302

The easiest way to allow many many many scenarios imho would be to do this as follows:

 

  • Allow the launch command to point to a powershell file to execute it
  • Provide a configuration on the app or tenant settings that toggles "enable local machine access" (default off), to enable this to work or not
  • The powershell file runs in the context of the logged on user on the local machine
  • the powershell can return information to the app
  • the launch command has a true/false parameter to wait for the powershell execution to complete or not

This would enable a gazillion scenarios where you might want to create a local file, print, or run any type of script by clicking a button in the power app that today people are trying to find workarounds for via Flow and on premise gateways etc...

 

I have seen examples of Launch to open a web page, to dial a phone number, to send an email, etc... so a lot of the plumbing is already there.

Categories:
I have the same question (0)
  • rimatos Profile Picture
    on at
    Re: How to run powershell from a powerapp

    Hi @bouillons

     

    Currently there is no connector for PowerShell available to be used in either Flow or PowerApps. as such, there is no direct way to tap into this directly.

     

    with this in mind there are only 2 possibilites that come into my mind that could be used as a workaround for this issue.

     

    1. Create a Custom Connector

     

    This option would require you to create a custom connector that would tap directly into PowerShell API, although I'm not exactly sure how this could be accomplished.

    Information on creating  custom connectors is available here.

     

          2. Use a UI Flow for Desktop.

     

    In this option you would need to create a UI Flow for desktop. This would tap into some of your points provided such as:

    • Launching Powershell Script
    • Run in context of logged user
    • Return information to app

     

    You can use UI flows to automate repetitive tasks in Windows and Web applications. UI flows records and plays back user interface actions (clicks, keyboard input, etc.) for applications that don't have easy-to-use or complete APIs available.

     

    To achieve these points and return back the results, you would need to incorporate the UI Flows action into a Flow which could be acceded through PowerApps.

     

     

    Hope this helps!

     

    Regards,

    Ricardo 

     


     

  • bouillons Profile Picture
    302 on at
    Re: How to run powershell from a powerapp

    The problem with these workarounds is that it is my understanding that they run in the infrastructure of the flow platform. What I need is to run this on the machine that launched the power app. How would this work with a UI flow ? Which UI does this control ? Does it control actions that normally the user would take himself on his local machine ? Under which user does this run ?

  • rimatos Profile Picture
    on at
    Re: How to run powershell from a powerapp

    Hi @bouillons 

     

    When you create a UI Flow, one of the prerequisites you have is to first set up a on-premises gateway for the device where the UI Flow will be triggered. This is due to the fact that the UI flow will need to have access to the local machine to execute the actions that you want to automate for the user.

     

    When you create this UI Flow you will need to use the same account for setting up the gateway, and to use as credential in the UI Flow connection, When doing this you are assuring that the UI flow is being executed as the user you have set up here.

     

    You have some additional documentation here for executing unattended and attended UI Flows, that might help clear some of these questions: https://docs.microsoft.com/en-us/power-automate/ui-flows/run-ui-flow.

     

    Let me know if this helps!

     

     

    Regards,

    Ricardo

     

     

  • bouillons Profile Picture
    302 on at
    Re: How to run powershell from a powerapp

    I tried to record a UI Flow to perform the following action

     

    "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE" "c:\temp\Ticket-18.xml" /mFilePrintDefault /mFileExit /q /n

     

    Basically, what I want is to open a file in word, print it out and close word

     

    When testing it always fails, because the recorder just starts word and then sits there waiting. It doesn't open the file, but stays stuck on the Word Home page:

     

    The action in Flow generated by the recorder is just to start Word. If I try to add command line parameters it even fails to start Word at all

     

    Capture.JPG

     

  • rimatos Profile Picture
    on at
    Re: How to run powershell from a powerapp

    Hi @bouillons 

    When you recorded the steps or your UI flow did you verify if the steps all appeared in the actions? When you say print out your intent is to print the file?

    When you execute the Flow make sure that you are running it as attended, otherwise you will need to be logged out of the machine where the flow will execute in order for it to function.

    Additionally, you can also try and contact Microsoft Support through https://admin.powerplatform.microsoft.com/support in order to troubleshoot this in more depth.

     

     

    Regards,

    Ricardo

  • Max44 Profile Picture
    223 on at
    Re: How to run powershell from a powerapp

    Save-Module -Name Microsoft.PowerApps.Administration.PowerShell -Path
    Import-Module -Name Microsoft.PowerApps.Administration.PowerShell
    Save-Module -Name Microsoft.PowerApps.PowerShell -Path
    Import-Module -Name Microsoft.PowerApps.PowerShell

  • axorth Profile Picture
    14 on at
    Re: How to run powershell from a powerapp

    All of these options seem way over complicated. Why not just setup an Azure Automation account and use the "Create Job" step to execute it?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 757 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 322 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 209 Super User 2025 Season 2

Last 30 days Overall leaderboard