# How to call PowerShell script from python

**URL:** <https://forums.powershell.org/t/how-to-call-powershell-script-from-python/19028>\
**Category:** PowerShell Help\
**Created:** [April 6, 2022, 10:56am UTC](https://forums.powershell.org/t/how-to-call-powershell-script-from-python/19028 "2022-04-06T10:56:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shanmugavel](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Shanmugavel](https://forums.powershell.org/u/Shanmugavel)\
**Post date:** [April 6, 2022, 10:56am UTC](https://forums.powershell.org/t/how-to-call-powershell-script-from-python/19028/1 "2022-04-06T10:56:09Z")

</div>

Hi Team,  
How to call PowerShell script from Python.  
I Have installed Python 3.7 and Powershell 7 version  
I am running the below python script to call a PowerShell script

```auto
import subprocess, sys
p=subprocess.Popen(["c:\program files\powershell\7\pwsh.exe". "c:\scripts\abc.ps1"], stdout=sys.stdout)
p.communicate()

```

Getting the below error  
File “c:\program files\Python37\lib\subprocess.py”, line 775, in\_init\_ restore\_signals, start\_new\_session)

Thanks  
Vel

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 6, 2022, 11:58am UTC](https://forums.powershell.org/t/how-to-call-powershell-script-from-python/19028/2 "2022-04-06T11:58:53Z")

</div>

I cannot tell nothing about Python but when you run

```auto
pwsh /?

```

in a CMD or PowerShell console it will tell you the proper syntax to call PowerShell with a script file. 😉

BTW: When you post code, sample data, console output or error messages please format it as code using the _preformatted text_ button ( **\</\>** ). Simply place your cursor on an empty line, click the button and paste your code.  
Thanks in advance  
[How to format code in PowerShell.org](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif)

---

<div class="post-metadata">

**Author:** ![skyangel](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@skyangel](https://forums.powershell.org/u/skyangel)\
**Post date:** [November 21, 2022, 11:55pm UTC](https://forums.powershell.org/t/how-to-call-powershell-script-from-python/19028/3 "2022-11-21T23:55:25Z")

</div>

Please I tried adding users to an organization unit using PowerShell script it worked but the users are not showing on the organization unit. PowerShell scripts. it was created on my member server .What do I do

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 27, 2022, 9:30pm UTC](https://forums.powershell.org/t/how-to-call-powershell-script-from-python/19028/4 "2022-11-27T21:30:14Z")

</div>

Oyinkansola,  
Welcome to the forum. 👋🏽

Please do not hijack other members threads - especially when they are actually unrelated to your issue. Instead create a new question for yourself an place a link to the question you think is related in your question.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [February 10, 2024, 5:34pm UTC](https://forums.powershell.org/t/how-to-call-powershell-script-from-python/19028/5 "2024-02-10T17:34:06Z")

</div>

Closed on February 10, 2024, 5:34pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
