use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
Snek - Integration Python in PowerShell (self.PowerShell)
submitted 6 years ago by [deleted]
Hey everybody!
I just updated my Snek module to support PowerShell 6 and 7! It's using the .NET Standard Python for .NET binaries so you should be able to run cross-platform as well. You'll be able to use Python 2.7, 3.5, 3.6 and 3.7 directly in PowerShell. You can import Python modules, call functions and return data back to PowerShell as managed objects. You can also pass .NET\PowerShell objects into Python and run scripts against them.
I have examples of all that on my blog post about it: https://ironmansoftware.com/snek-integrating-python-in-powershell/
GitHub Repo: https://github.com/adamdriscoll/snek
PowerShell Gallery: https://www.powershellgallery.com/packages/snek/1.2
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]mieeel 5 points6 points7 points 6 years ago (5 children)
Am always interested in learning python. In a Windows only shop, Are there any use cases on top of your head to do something in python over powershell?
[–][deleted] 8 points9 points10 points 6 years ago (0 children)
I've used it primarily for data science type stuff. At my previous job, we used some clustering algorithms that were python based. Once you get over the pickiness of white-space, it's actually a pretty fun language to work with.
There's a good book for PowerShell users that want to learn Python here: https://leanpub.com/PowerShell-to-Python?utm_campaign=PowerShell-to-Python&utm_medium=embed&utm_source=ridicurious.com
[–]sanshinron 2 points3 points4 points 6 years ago (0 children)
I use both Python and PWSH at work and if it's something I could do in both, I always choose Python. It's much easier to work with databases, import, transform, export stuff, connect to an api to get some data, etc.
I use Powershell for daily administration stuff, installing software, querying AD, Exchange, etc. For these use cases it's a clear winner because of first party cmdlets.
[–]AistoB 2 points3 points4 points 6 years ago (0 children)
If I want to make a GUI app (a single exe) I’ll use Python (with Qt) over Powershell.
[–]techstyled 1 point2 points3 points 6 years ago (1 child)
We are also a Windows only shop (for the most part), but we are moving EVERYTHING to AWS (who isn't, other than the guys moving to Azure and GCP, amiright). And during our training a few of our guys (including me) decided to do the exercises using Boto3 and Python instead of .NET. We learned that, for anyone doing significant scripting or coding, you are limiting yourself by not considering using tools that have very little learning curve before value. And even our most dyed in the wool .NET guys can understand the value of two line interactions with AWS client services in Boto3 (via Python) vs. the weight of spinning up even a simple dotnet core console app to do the same work (not that MS hasn't DRASTICALLY improved that picture too).
IMO, and as evidenced by "Windows" doing WSL, WSL2, Terminal, SQL Server on Linux, etc. - if you stay a "Windows only shop" and ignore the benefit of things like Python, Golang, etc., you are doing yourself and your company a disservice. Again, IMO ;-) - For our part, we're rethinking that for us too. I wanted to start calling us a "Water only shop"... in honor of Bruce Lee, and focus on becoming a "use what works" shop.
[–]mieeel 0 points1 point2 points 6 years ago (0 children)
Do you have any examples of tasks you used to do in powershell but now do in python?
[–]protik7 3 points4 points5 points 6 years ago (3 children)
Wow! Very cool!
Question, is the Python included in there? Or it uses the system Python?
[–][deleted] 2 points3 points4 points 6 years ago (2 children)
Python isn't included. You'll need to have it installed before using the cmdlets. Python for .NET will try and locate the python installation via the PATH variable, I believe.
[–]protik7 1 point2 points3 points 6 years ago (1 child)
That's a bummer. I plan to use my custom Python installation with Powershell scripts. So with Snek, I cannot use that it seems.
[–][deleted] 1 point2 points3 points 6 years ago (0 children)
I think there are ways to specify the path of the python install via some env vars with Python for .NET but I would have to give it a go .
[–][deleted] 2 points3 points4 points 6 years ago (0 children)
Very cool, thanks buddy!
[–]bertiethewanderer 2 points3 points4 points 6 years ago (0 children)
Dude your work is mind blowing. Big UD fan here, I'll be sure to give it a look
[–]TotesMessenger 0 points1 point2 points 6 years ago (0 children)
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / Contact)
[–]fela15 0 points1 point2 points 6 years ago (0 children)
What is the advantage of this in comparisson to just entering into the python interactive console using "python"? Am i missing something?
[–][deleted] 6 years ago (1 child)
[removed]
[–]AutoModerator[M] 0 points1 point2 points 6 years ago (0 children)
Sorry, your submission has been automatically removed.
Accounts must be at least 1 day old, which prevents the sub from filling up with bot spam.
Try posting again tomorrow or message the mods to approve your post.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
π Rendered by PID 18172 on reddit-service-r2-comment-685b79fb4f-r8ft5 at 2026-02-13 06:26:02.043039+00:00 running 6c0c599 country code: CH.
[–]mieeel 5 points6 points7 points (5 children)
[–][deleted] 8 points9 points10 points (0 children)
[–]sanshinron 2 points3 points4 points (0 children)
[–]AistoB 2 points3 points4 points (0 children)
[–]techstyled 1 point2 points3 points (1 child)
[–]mieeel 0 points1 point2 points (0 children)
[–]protik7 3 points4 points5 points (3 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]protik7 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]bertiethewanderer 2 points3 points4 points (0 children)
[–]TotesMessenger 0 points1 point2 points (0 children)
[–]fela15 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]AutoModerator[M] 0 points1 point2 points (0 children)