Python, PowerShell, or Other? [closed] Python, PowerShell, or Other? [closed] python python

Python, PowerShell, or Other? [closed]


Python works as a great, all-purpose tool if you're looking to replace CMD and BAT scripts on your Windows boxes, and can also be written to run scripts on your (L)inux boxes, too. It's a great, flexible language and can handle many tasks you throw at it.

That being said, PowerShell is an amazingly versatile tool for administering all manner of Windows boxes; it has all the power of .NET, with many more interfaces into MS products such as Exchange and Active Directory, which are a timesaver. Depending on your situation, you may get more use of of PS than other scripting languages just because of the interfaces available to MS products, and I know MS seems to have made a commitment to providing those APIs in a lot of products. PowerShell comes installed on all current versions of Windows (Windows 7+, Windows Server 2008+), and is fairly easily installed on older versions.

To address your edit that your scripts will be used to launch other processes, I think in that case either of the tools fit the bill. I would recommend PS if you plan on adding any admin-ish tasks to the scripts rather than just service calls, but if you stick to what you described, Python is good.


We would like to standardize our scripting and are currently using bat and cmd files as the standard.

It sounds like Windows is your predominate environment.

If so, PowerShell would be much better than Python.

  • PowerShell is included with WindowsServer 2008. No need todeploy/install Python runtime onevery new server that rolls in.
  • The entire Microsoft server related software (Exchange, Systems Center, etc) is transitioning to PowerShell cmdlets for functionality and extensions
  • 3rd party vendors (e.g. SCOM plugins) will also use PowerShell scripts/cmdlets to expose functionality

I have more experience with Python than PowerShell but the writing is on the wall as far as the Microsoft ecosystem is concerned: go with PowerShell. Otherwise, you'll just be going against the grain and constantly interop-ing between Python and everyone else's cmdlets.

Just because you can code import win32com.client in Python does not put it on equal footing with PowerShell in the Windows environment.


IronPython has access to all of the same .NET assemblies as any other .NET language for writing system dependent scripts on Windows. But the same knowledge of Python can be used to write similar scripts on Linux, Solaris, BSD, or OS/X. If you use the standard C Python on Windows, then you can access any COM objects and it is straightforward to translate VBA examples into Python code. The SPAMBayes Outlook plugin is a good example of how far you can go with that. http://spambayes.sourceforge.net/

Python's best feature is the "batteries included" standard library, and even though this is not distributed with IronPython, much of it will work if you just point IronPython to the installed library folder from CPython. In fact, most pure Python libraries, i.e. no compiled C or C++ modules, will work fine with IronPython. On Windows, you also have the choice of installing Python through Cygwin.com which then allows you to use a lot of modules that are normally considered UNIX-only. This can be of use if you have to maintain cross-platform scripts and you prefer consistency rather than special case coding for each OS.

And if you should need to leverage some Java classes, then Jython allows you to use the same Python language that you know to leverage this. Combine this with a nice message queuing system like RabbitMQ, and you can have Python, Jython and IronPython scripts on multiple machines all cooperating in getting the job done.

There is also a huge selection of 3rd party Python modules out there and you could spend several months trawling through delicious.com before you run out of new discoveries. This means that when you need something not part of standard Python libraries, a bit of Googling often comes up with a solution.

Some useful Python modules for scripting to replace bash, CMD and BAT files are PEXPECT http://www.noah.org/wiki/Pexpect and Python WMI http://timgolden.me.uk/python/wmi/index.html

But, in the end, Python also works just fine for simple straightforward scripts that don't need any special features... yet!