473,586 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running Python Script in Powershell

4 New Member
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
Sep 16 '08 #1
3 7328
Nepomuk
3,112 Recognized Expert Specialist
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)
Sep 16 '08 #2
shalong
4 New Member
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
Sep 17 '08 #3
Smygis
126 New Member
Try and see if powershelter has someting like pythons -c flag.

Expand|Select|Wrap|Line Numbers
  1.  
  2. >>> import os
  3. >>> os.popen('''python -c "print 'hello'"''').read()
  4. 'hello\n'
  5. >>> os.system('''python -c "print 'hello'"''')
  6. hello
  7.  
  8. >>> 
  9.  
One would think powershell has something similar.
Sep 17 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1961
by: BartlebyScrivener | last post by:
The Windows Powershell is available, fka Monad. Any special Python tricks? Just breezing through the manual, they seemed to have borrowed from any language they wanted in making a new scripting language. http://tinyurl.com/l9ghj rd
5
2600
by: Neil Chambers | last post by:
Hi All, I'm looking to see if it's feasible to use the SortObjectCommand included in the Microsoft.Powershell.Commands assembly. I have a Dictionary Dictionary<string, intd = new Dictionary<string, int>(); d = new int;
3
2672
by: =?Utf-8?B?VGhvbWFzIFcuIEJyb3du?= | last post by:
1. Is there a dedicated discussion group for Windows Powershell? I couldn't find one, but that doesn't necessarily mean there isn't :-) 2. I'm just starting in on learning to use Powershell and doing so by slowly (very slowly) attempting to port some existing CMD and Perl scripts. I'm blocked right now on something that should be very...
6
16539
by: Mesan | last post by:
Does anyone have an idea what it takes to administer DB2 through PowerShell? I want to write some scripts to automate my common DB2 management tasks and I'd really like to be able to use PowerShell for that scripting, but I can't find a way to run DB2 comands. I've tried db2cmd /w db2cmd /w /i db2cmd /i (this one got me the closest)...
1
2559
by: Alexander Vasilevsky | last post by:
Hi! How to debug Powershell commandlets? -- http://www.alvas.net - Audio tools for C# and VB.Net developers
2
3158
by: jetoo | last post by:
Hi there, i'm trying to run a powershell script from a aspx page. Here's the code: //Powershell arguments String powershell = "C:\\WINDOWS\\system32\ \windowspowershell\\v1.0\\powershell.exe";
5
6762
by: josepharmbruster | last post by:
I am all about using the right tool for the right purposes, which is why I have started reading the GettingStarted guide to PowerShell. I am curious if any other pythoneers have ventured into the world of PowerShell. Mostly, I am interested in grabbing perspectives on the differences noticed from those that have working experience with using...
0
1589
by: eddiefisher41 | last post by:
Hey guys. Im having problems running a python cgi. Im using the example code from: http://www.python.org/doc/essays/ppt/sd99east/sld041.htm as writen by Van Rossum himself I can get the script to run the python script but all that happens is that the black python box appears then disapears, the html that the python scripts should generate is...
1
3130
by: =?Utf-8?B?YXVsZGg=?= | last post by:
i read the MS kb: Using Exchange Management Shell Commands With Managed Code http://msdn.microsoft.com/en-us/library/bb332449.aspx how ever i'm getting "{"No Windows PowerShell Snap-ins are available for version 1."}" exception when i try to call PSSnapInInfo info = rc.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out...
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.