Home:ALL Converter>Using Python script to run a full independent powershell script

Using Python script to run a full independent powershell script

Ask Time:2018-08-12T11:59:37         Author:Pierry Louis

Json Formatter

I am a noob, self-motivated programmer, and had been researching methods to use my Python script to run a Powershell file that will copy and image and place the image into Excel.

I've used the subprocess, call, and Popen commands in an attempt to call and run the Powershell program from the Python script, but none has worked.

Some of the examples I found only called different functions of a Powershell script, but when I tried those settings it didn't work for my program. All of the setup for my Powershell has been established so that it can run with my PC, and also runs well when launched independently from Python.

What I would like to ask is if I had, for example, a My_program.py file and a Moving_image.ps1 file. I want to use my .py file to run/execute my .ps1 file, while both programs are located in the same path (C:\Users\Scripts).

What line of code(s), imports, and other program setup's would I need in my Python file to simply run the independent .ps1 file from my Python script?

I don't need the Powershell script to return anything to the Python script. I would like for it to simply run the copy and paste the command I sent it.

Thank you. Any type of guidance that will lead to this program actually functioning properly will be most appreciated!

Author:Pierry Louis,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/51805568/using-python-script-to-run-a-full-independent-powershell-script
yy