[Tutor] pass argument from python to powershell

phanidhar kunnu531 at gmail.com
Sat Dec 14 13:57:11 CET 2013


Hi All ,

I am very new to python and really like to learn it .

Have a code which is powershell script and i want to execute this script
using python .

example of powershell script content is :

get-aduser $args[0]

Python script :

import subprocess
import os

a =
subprocess.Popen([r'C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe',
'./aduser.ps1'])
result = a.wait()

so when i run the python script it displays all the output of AD users but
not the argument alone i give.

If I change my powershell script to "get-aduser kunnu" and run the python
code it display the output of my account alone which doesnt happen when i
give it as an argument .

so how do we pass an argument in python while executing where the value
gets enterred in powershell script and displays the output i required...

Thanks,
Kunnu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131214/7b57bf11/attachment.html>


More information about the Tutor mailing list