Running Python Script in Powershell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalong
    New Member
    • Feb 2008
    • 4

    Running Python Script in Powershell

    Hi all,

    I want to run a python script to create a large number of Exchange mailboxes.
    I am using the os.system("New-Mailbox.......) method.

    However if i try to execute the python script in powershell it runs it in simple old cmd prompt (which dosent have cmdlets such as New-Mailbox)

    Is there any way I can run the python in powershell or will i have to go and write a .ps1 script??

    Thanks,
    Shalong
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Hi Shalong!

    Although the Windows PowerShell is a Microsoft Product, I guess the Python experts can help you much more with this question than the Windows team can. Therefore, I'm moving this to the Python Forum.

    Greetings,
    Nepomuk (Moderator)

    Comment

    • shalong
      New Member
      • Feb 2008
      • 4

      #3
      Thanks Nepomuk,

      For the time being im just printing everything generated by the python script to a .ps1 file and running this file in powershell.

      Shalong

      Comment

      • Smygis
        New Member
        • Jun 2007
        • 126

        #4
        Try and see if powershelter has someting like pythons -c flag.

        Code:
         
        >>> import os
        >>> os.popen('''python -c "print 'hello'"''').read()
        'hello\n'
        >>> os.system('''python -c "print 'hello'"''')
        hello
        0
        >>>
        One would think powershell has something similar.

        Comment

        Working...