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 / Run Python Script in C...
Power Automate
Unanswered

Run Python Script in Cloud Flows

(0) ShareShare
ReportReport
Posted on by 20

Hello everyone,

I have developed a Python script that aims to transform a tabular file into an Excel file. This Python script defines the columns I want to have based on the number of characters and also defines their data type (string, float, date, etc.).

I receive a tabular file daily on an SFTP, so I created a flow that triggers when a file is created or modified on the SFTP, and then copies it to a specific SharePoint folder.

Now comes the part where I am having difficulties. My idea was to run the desktop flow in unattended mode as the next action. However, when I do this, even though the cloud flow was considered "succeeded," when I check if the Excel file exists in the SharePoint folder, it is still in its original tabular file format. My Power Automate flow is very simple, it has two steps. The first is a set variable where I indicate where my .py script is located, the second step is to "run PowerShell" where I have "python" and then the variable I created in the previous step.

If I run this manually in Power Automate Desktop, I will be successful in transforming the file. However, if I do it via the cloud flow and invoke Power Automate Desktop in "unattended" mode, it doesn't work.


Can anyone help?

Thank you!

I have the same question (0)
  • lbendlin Profile Picture
    8,709 Super User 2026 Season 1 on at

    Specify the full path to the python executable. Make sure the PAD process user has access to it.

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @bdpr_95 

     

    Since you told that you are running powershell script, in powershell script, under variables there is an option to enable variable for capturing errors, just enable that and run in unattended mode, see any error is shown or not, use out argument to get that error value from desktop to cloud 

     

    Hope this helps 🙂

     

  • bdpr_95 Profile Picture
    20 on at

    Hello @Nived_Nambiar, the problem here is that the flow is running correctly and doesn't show me any errors (even though I have activated the option to show me errors if I have them).

    bdpr_95_0-1683726970719.png

     

  • bdpr_95 Profile Picture
    20 on at

    @lbendlin, the PAD has access to it. If I run the PAD manually it works, but if I create a cloud flow to run this flow automatically, it doesn't work.

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @bdpr_95 

     

    the powershell script won't throw any error , it just stores the details of error in that error variable and move on.

     

    So once you were able to retrieve the error variable from desktop flow run, check if it contains value, if it contains value it means error occured while running the powershell script so what you can do is use Terminate action to terminate the flow with error message as obtained from powershell script error output 

    Nived_Nambiar_0-1683738941688.png

     

     

    Hope this helps !

     

     

  • bdpr_95 Profile Picture
    20 on at

    Hello @Nived_Nambiar, the Terminate Action works for succeeded cloud flows?

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @bdpr_95 

     

    You can use Succeded option in Terminate flow to make it as succeeded 🙂

     

    Nived_Nambiar_0-1684168814618.png

     

  • bdpr_95 Profile Picture
    20 on at

    @Nived_Nambiar in this case, which option should I choose? Is that the flow when running is considered as "succeeded".

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @bdpr_95 

     

    when powershell did not run as expected, it will store the error details in ScriptError variable, you can pass the variable from desktop flow to cloud flow using output variables, 

     

    Then we will check if that output value is null or not, if it is not null, it means there is an error in running powershell script so we need to stop the flow as failed, for that we will be terminate flow with failed status with error reason as script error 

     

    Nived_Nambiar_0-1684169601949.png

     

     

    For your case this terminate action is fine 

  • bdpr_95 Profile Picture
    20 on at

    @Nived_Nambiar this was the output:

    {

        "scriptOutput": {

            "localizedName": "Output",

            "value": "",

            "variableName": "PowershellOutput"

        },

        "scriptError": {

            "localizedName": "Error",

            "value": "C:\\Program : The term 'C:\\Program' is not recognized as the name of a cmdlet, function, script file, or operable \r\nprogram.  ...",

            "variableName": "ScriptError"

        }

    }

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 840

#2
Valantis Profile Picture

Valantis 661

#3
Haque Profile Picture

Haque 589

Last 30 days Overall leaderboard