Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question nicely covers getting python scripts running under CMD.EXE without having to type a bunch of extra stuff - that is "> script" rather than "> python".

However, I can't seem to get the same behavior under PowerShell. Entering "PS >" there just gets me the "is not recognized as a cmdlet, function, operable program, or script file" error.

How do I get PowerShell to recognize the same file associations that CMD does?

share|improve this question
up vote 2 down vote accepted

Aha, I've found the answer myself.

In PowerShell, scripts to be executed need to be proceeded by ".\"

So, "PS >" doesn't work, but "PS > .\" does.

Also, using this syntax adding ".py" to PATHEXT works fine under PowerShell.

share|improve this answer

Completely different direction but you could use IronPython to make .net executables and call those.

share|improve this answer

The same solution should work under Powershell: did you try adding .py to the PATHEXT environment variable?

share|improve this answer
Yes. Clearly, PowerShell isn't looking at the environment variables for this kind of thing. – Electrons_Ahoy May 14 '09 at 4:50
Scratch that, yes it is; I was just running commands the wrong way. See my answer. – Electrons_Ahoy May 14 '09 at 6:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.