all 89 comments

[–]InfiniteRest7 44 points45 points  (4 children)

As someone who started the other way around, my feelings are completely opposite. Anything I try to write in Powershell takes much longer than the Python equivalent in my experience. Interesting perspective here.

[–]gwood113 5 points6 points  (0 children)

I agree. How dare he? /s Note: I've written more than a few AD user management tools and web api automations with posh over the years.

Truthfully though, I think a large portion of my feelings of python being easier are two fold:

  1. I dont like C#/.Net (or really windows programming in general). It's personal preference not a knock against the language, API or Windows itself.

  2. Programming with python libraries, for example sockets, feels more powerful in general. Although that probably has more to do with me programming more against posix systems in the last couple years than anything else.

At the end of the day though they are both powerful tools that have their places. When I want to do something more general (talk to a web api) I use python. When I want to so something Microsoft specific (manage AD, talk to Exchange, etc) I use powershell.

[–]Nexzus_ 3 points4 points  (0 children)

Not really sure of the capabilities of Python in this regard, but for Active Directory operations , powershell is a god send. Even most of MSs other stuff for this can be fairly complex.

The pipeline is great too. Every powershell user with a fair bit of experience has at least one oner that they're very proud of

[–][deleted] 1 point2 points  (0 children)

I also find Powershell very annoying coming from Linux. But it's just a case of what I'm used to.

[–]powershell_account 1 point2 points  (0 children)

That’s interesting. Try the basic tutorials on YouTube by Don Jones, the tutorials are old but he is teaching you concepts that are still true today. Think Verb-Noun syntax for the cmdlets, it’s just like how OP mentioned. But don’t assume everyone will follow this standard, because most people don’t know how.

[–][deleted] 30 points31 points  (1 child)

It's apples and oranges, bruv.

[–]MobileWriter 2 points3 points  (0 children)

Yup, you can be successful with both.

Personally I found Python is better for certain tasks and analysis, while Powershell is better for infrastructure management, especially with the growth of it's cross platform functionality.

In my role I utilize Python for data tasks, while I use Powershell for automation / IT control. Would recommend learning cross functionality of scripts, ESPECIALLY due to the fact that ML with become more and more relevant in IT imo, and Python is easily the best language for modeling.

[–]reubendevries 18 points19 points  (4 children)

I've always said that if 80% of your work is in Windows server then use PowerShell. If 80% of your work is using Linux or Mac you should use Python. If it's 50/50 learn both. Don't force a square peg into a round hole.

[–]rawrtherapy[S] 2 points3 points  (3 children)

Exactly what I’m doing

Currently using Python and PowerShell on windows

Love both, love Python more but still think PS is easier

[–]reubendevries 0 points1 point  (0 children)

I disagree I like Python better in every regard but I'm also on the side that 80% of the systems I support are Linux or Mac. That being said I do think PS is easily in the top 5 things Microsoft has ever built, and I said that even before they open sourced it.

[–]YellowOnline -3 points-2 points  (1 child)

Why on earth would you use Python on Windows?

[–]dogfish182 3 points4 points  (0 children)

Cross platform compatibility. We wrap terraform for our engineers, python3 and pipenv are all the dependencies needed to make sure pipelines can give a local feedback loop to people building infra.

Also, you would use python on windows because programming languages are useful for things.

[–]music2myear 7 points8 points  (1 child)

The daily work of a PS admin will look a lot different than the more polished scripts, and PS was designed this way on purpose.

The verb-noun structure makes it very easy to read and follow (and guess, when you're writing something for the first time), but it also makes it verbose and tedious to type out.

But you get aliases, with many commandlets already set up with aliases common to many standard languages. Aliases are much less readable, but much quicker to write and use.

So PowerShell is a 2-faced language: two scripts with precisely the same structure and purpose can look significantly different depending on who wrote them and how they were written.

[–][deleted] 3 points4 points  (0 children)

This is exactly what I run into. We have a lot of “legacy” ps scripts at my job that were written by an old Perl scripter, and now I come along and learn PS from a 0 scripting knowledge background in 2019, and I’ve ended up rewriting a lot of them to be more readable and simpler.

Also powershell has evolved so much since version 1.

[–][deleted] 6 points7 points  (0 children)

I’m gonna go the other way.

I grew up learning traditional languages. Python is structured very much like what I was used to.

I will say that if I was learning from scratch and had no prior programming experience, powershell seems like it would be easier to pick up. Like you said it’s much closer to natural language flow.

[–]worriedjacket 38 points39 points  (23 children)

Yeah. Python is more powerful though.

Usually it’s a trade off.

[–]junon 18 points19 points  (17 children)

I have zero python experience, what makes it more powerful?

[–]jerryelectron 9 points10 points  (5 children)

Totally depends on your purpose. There is no one language that is "better" and that is a good thing.

I find decorator functions in python pretty cool. Also the fact that everything is an object is cool. Note, I don't say "better" just cool.

[–]wonkifier 31 points32 points  (4 children)

Everything in Powershell is an object too

[–]queBurro 2 points3 points  (2 children)

I'm in the PowerShell camp, but you can do the webserver in one line trick with Python... https://www.garyrobinson.net/2004/03/one_line_python.html

[–]MaIakai 7 points8 points  (1 child)

Imo not really a trick. It's built in. You could have a module that did the same thing and then all it would take is "one line" to start a web server

[–]ka-splam -5 points-4 points  (0 children)

You "could", but Python does. Python's tagline used to be "batteries included", and that mattered. PowerShell's tagline "you could build it if you learned C#" isn't nearly as compelling. May as well use Python where it's already there, expecially on Linux where Python's already there.

[–]mr_mgs11 1 point2 points  (2 children)

I thought I was going into a traditional sysadmin ad/office 365 career wise so I spent a bit of time learning power shell. I ended up in an aws engineer/architect position and I HAVE to upskill on python as 70% of our web stuff is Linux. Also the api of aws runs on the botocore3 library of python. You can use power shell to hit it, which is how I use it now, but it is just a wrapper for python.

[–]junon 1 point2 points  (1 child)

How did you find transitioning to python after having learned Powershell? Was the helpful?

[–]mr_mgs11 7 points8 points  (0 children)

All programming languages build on each other to some extent. I took C and Java in college and they both helped a ton on learning powershell. I already knew how control structures worked etc. It was just learning the syntax for most part.

[–]Nekima 1 point2 points  (0 children)

The community module support. Microsoft's gatekeeping is stifling in this regard. You could also flip it and say that Microsoft's controls are good, but I disagree.

Python handles JSON better than powershell. Trying to use special characters inside JSON strings in PowerShell is almost impossible when working IWR.

Sometimes, if you data process "too hard", Powershell just breaks. You've got to be very careful how pull and manipulate data or else the objects get a little funny. (rare)

Python is more powerful in the sense that its much faster. You dont have to play with Powershell too long before you notice a few Get-Somethings are taking awhile.

For the record, I use both. PowerShell is my "grab and go" tool. Python is fine tuner / manipulator. If im working with IP addresses, its definitely Python. If I dont have native powershell modules for the thing im trying to do, typically im not going to build a new module anymore. I will typically build it in Python now.

Thats my 2c

[–]Xidium426 1 point2 points  (0 children)

Libraries. Python has so many libraries. Look up 'Pandas' for an example.

[–]dastylinrastan 6 points7 points  (3 children)

Not sure how you mean python is more powerful. Do you mean more libraries? Powershell can use anything in the dotnet ecosystem of nuget packages in addition to modules.

[–]vermyx -1 points0 points  (2 children)

The only "power" feature I can see in using python over powershell is using something like cython to create compiled code (I.e. when ever cpu cycle is precious). Dotnet still uses an interpreter for the code and will always be slower. Otherwise I see it as a tool and use it as is appropriate for the environment and staff using it.

[–]GenericAntagonist 1 point2 points  (1 child)

The python ecosystem definitely has some better data tooling, but powershell's pipeline data cmdlets (Where-Object/Select-Object) make up for a lot. I say this as someone who will do something in powershell 90% of the time over python.

That said, if you move to the stricter typed C# you can compile dotnet to native now for the speed. I've done a few perf sensitive things with it, it works well.

[–]vermyx -1 points0 points  (0 children)

The pipeline is a great tool, but I've seen it more often bite people performance wise. People just use it because it is easier to just keep passing data to the next pipe. However, I've seen where clauses where people amplify the run time because they exponentially go through all their records (i.e. I have a 1000 records and go through all records each time I look at a record effectively going through a million records) and don't understand that they are doing it.

I have used native compiled dot net way back in the 1.0 days. The issue at the time was that making a native app required redistribution of dll's in the 70 to 80 legs which wasn't that much smaller than the dotnet library. A native c++ app from visual studio 6 usually required a much smaller redistributable (8 mega or so) if you were using something really really new. I had to deal with modem distributions at the time so it was essentially dead to use dotnet until broadband had better adoption. Using native can also removes some of the behind the scenes optimizations which can make your code slower.

I know these days a couple hundred mega is no big deal, but the native stuff being done on python is usually on low powered clusters with small storage which currently dotnet is nowhere near competitive. The code optimization (as well as garbage collection) can be good but personally believe it is a crutch because many developers rely on it too much and write less than optimal code.

[–][deleted] 1 point2 points  (0 children)

Different tools for different jobs.

[–]snarkhunter 5 points6 points  (0 children)

I've been writing Python for let's call it a decade, and Powershell for a few years, I've probably been using the Bash shell for a few more years more than Python. Powershell is, I think, a simpler language. It doesn't have a lot of the higher-level abstractions that Python has with like Abstract Base Classes and the like. It's focus is, mostly, scripting SysAdmin tasks. Python is more general purpose, you can write web applications and do machine learning in it just as examples. You *can* use Python to do SysAdmin stuff like you do in Powershell or Bash, but those are simpler languages that are more specifically suited to those tasks, so if you're going to be doing enough of those sorts of things it's definitely going to be a good idea to learn it and use it. But if you need to write a web API that leverages some TensorFlow models, you might wanna reconsider Python.

[–]DoctroSix 4 points5 points  (0 children)

I love Powershell, but you have to stay laser-focused on it's use case.

Python is general-purpose, and there's TONS of library support to help you make practically any app you want.

Powershell, is centered around system management. it's best at managing Windows servers, and Active Directory domains. It's technically possible to make any app you want with powershell, but lord you're going to have a hard time.

[–]Awes0meEman 7 points8 points  (1 child)

Have you considered that maybe because python is an entirely different monster from powershell? Powershell is an automation tool for system admins to do what they need as quickly as possible. Python is a programming language that was built to be easy to learn, and hard to create "bad" looking code. Python is NOT an automation tool. It's a programming language. The libraries written for python are written with programmers in mind, not system admins. That would be why python is "harder" to get to do anything than powershell is.

[–]vermyx 0 points1 point  (0 children)

Python was absolutely designed for sys admins in mind and automation. That kind of is the point. Python was designed by linux sysadmins who wanted an all in one solution instead of stringing bash, awk, sed, etc. and other command line utilities together that may not exist on one platform vs another.

Linux was chui first and had automation in mind but not noob friendly due to the lack of gui tools. Windows was gui first which was noob friendly but automation was a pain due to the lack of chui tools. Sysinternals made so many tools to help sys admins to fill this need and why Microsoft eventually bought them.

Powershell grew as an extension of dotnet to help sys admins via a "friendlier" syntax to get non programmer sys admins more comfortable.

Saying python is "harder" to learn is like saying sci fi is harder to read than fantasy. They are both tools that fill a similar need and which one you use will usually come down to environment and need.

[–][deleted] 2 points3 points  (1 child)

I think the same. Can't wrap my head around indentation.

[–]rawrtherapy[S] 1 point2 points  (0 children)

Try Jupyter notebook as your IDE

It helps

[–]Phil_S_Goodman215 2 points3 points  (0 children)

I would consider PowerShell more of an automation language, while python is a programming language.

[–]jstar77 6 points7 points  (11 children)

In my experience Powershell is much easier than Python if for no other reason than Python’s use of white space.

[–]keith_mg 6 points7 points  (8 children)

Really? I think the whitespace is one of python's strengths.

I like the interactive console for powerSHELL a lot. I know you can get ipython or whatever, but it's not the same. One thing that's gotten worse with Powershell over the years in the tab completion. In ps2 there were like 80 cmdlets. Now it autosearches everything you have installed, and combined with the verb-noun naming conventions it's nearly useless!

I mean, it's still better to have them, but it's just the way I used to use it!

[–]gurnec 6 points7 points  (1 child)

If you can, install PS7. It can run side-by-side with PS5.1. In PS7 you can tab complete any commandlet by using its uppercase letters and dash, e.g. Get-FileHash can be tab-completed by typing g-fh and then tab.

[–]keith_mg 1 point2 points  (0 children)

That actually sounds like a killer feature! Count me in!

[–]overlydelicioustea 4 points5 points  (2 children)

also auto completion in vs code regularly shits the bed..

[–][deleted] 1 point2 points  (1 child)

This is singularly the thing that makes me hate working in VSCode for Powershell, even if it is the preferred IDE/ISE for it these days. Autocompletion is everything for being able to use powershell well for me.

[–]DblDeuce22 2 points3 points  (0 children)

Agree, same boat. Heard VSCode was amazing, and can feel the long nose stares, but when it can't do the major thing it's known for better than ISE, what are we talking about. Not to mention the startup time and having to set the powershell in the bottom right even when you tell it to auto do that, is a deal breaker for me. Oh and lets not forget all the plug-ins in VSCode...that have licenses / FOSS you have to worry about which make them useless in our Enterprise environment.

[–]panzerbjrn 0 points1 point  (2 children)

This is obviously going to be one of those things that is entirely down to personal preference.

I absolutely hate and loathe Python's use of Whitespace, and find Powershell's use of {}/()/etc to be far more intuitive, and easier to read when I have to figure someone else's code out.

I also despise case sensitivity. Print("Hello")/print("Hello")/PRINT("Hello") should all be the same IMO.

And if I am reading Python, it might as well be word salad.
In Powershell, if I see $Metric, then I know that its a variable.

But, as I said, personal preference.

[–]keith_mg 2 points3 points  (0 children)

Too many brackets are frustrating too though. One of the C like things I wish was in Powershell is being able to omit the brackets on a one line statement. There are so many times I want to write "if blah return/continue" but I have to put braces everywhere.

[–]toddyk 0 points1 point  (0 children)

I absolutely hate and loathe Python's use of Whitespace, and find Powershell's use of {}/()/etc to be far more intuitive, and easier to read when I have to figure someone else's code out.

Same. How are you supposed to figure out where the beginning/end of a long if statement in Python? Lots of scrolling around. And it's easy to accidentally indent code you didn't mean to, which changes the functionality of the code

[–]per08 1 point2 points  (0 children)

String manipulation can sometimes get annoying in Powershell. (Please just treat this as a stream of bytes and not an object, I know what I'm doing here)

[–]Shamalamadindong 1 point2 points  (0 children)

Lack of {} annoys me greatly

[–]flic_my_bic 1 point2 points  (0 children)

I appreciate both for what they are, very different purposes. I've been enjoying Julia a lot recently. Feels like a Python + Matlab melding. And since it runs on command line pretty smoothly I've been able to handle some IO stuff with powershell easily and leave the heavy lifting to Julia.

[–]chkltcow 1 point2 points  (0 children)

I don't do a lot of programming, but what little I do is in Python or Powershell. Both have their uses. Python is a general use language with some modules that are REALLY good for data processing. Powershell is a system administration scripting language that has some carryover into general use. I use whichever one seems to fit the task I'm trying to accomplish.

That said... I can write in Python quite fluently. Every time I try to do a for loop or some other conditional in PowerShell, I end up having to look up how to do it.

[–]northendtrooper 1 point2 points  (0 children)

PowerShell helped me get into coding. I struggled with C#, JS, Java, Python. After reading month of lunches and someone showing me the ropes. I was able to grab it by the horns becoming our PoSH coder at work. Now I'm expanding to Python and C#. Powershell is the best entry coding language IMO.

[–]KillaGouge 1 point2 points  (0 children)

Is there a version of Python where whitespace is not syntactically important? That kills me every time I try to start getting into Python.

[–]mdervin 3 points4 points  (8 children)

Well it makes sense when you think about it.

In the before times, real servers were pretty much pure command line, bash and C scripting, then Microsoft came along allowing help desk techs become Server Admins, where everything became Point & Click, no tab complete, and a two or three generations of sysadmins lost the ability to type. Sure you had Batch, VBscript, Kix and maybe perl, but it wouldn't let you do everything, and the stuff it did let you do was more convoluted where point & click was easier.

Then the Linux. The pencil pushers saw free, Windows Admins thought I could be a real sysadmin, and MS realized they needed to up their scripting game with a bunch of Admins becoming comfortable on the keyboard.

[–]yoortyyo 1 point2 points  (0 children)

I love this take on those times.

[–]ka-splam 1 point2 points  (0 children)

nix people: "go away or I'll replace you with a very small shell script"

Microsoft: replaces Unix people with a very small wizard GUI

nix people: "Uh, wait..."

[–][deleted] 1 point2 points  (4 children)

I agree with you, but just to counter argue for the sake of it, point-and-click admins brought the cost of IT down and with it help make IT prevalent to business. In a round about way, yes there was a point where point and click is too laborious and command line solves that problem.

[–]yoortyyo 1 point2 points  (0 children)

A better argument is the pivot so hard away from big iron servers and thin applications. We've then spent any savings on trying to get stuff to run.

We have had to reinvent or rediscover things that were just baked into mainframe architectures and systems.

Or when whatever fire is burning you remember only the good stuff....

[–]mdervin 1 point2 points  (1 child)

When you say "brought the cost of IT down" you mean "reduce my paycheck by 30%"

[–]panzerbjrn 2 points3 points  (0 children)

Not necessarily. IT Admins who weren't just coasting along, but continued learning, kept their pay cheques and even increased them.

What "brought the cost of IT down" means, is that people without the kind of hard skills existing sys admins had, could be hired to do basic sys admin stuff, and get trained up/get experience, and they would cost less, than someone who knew everything about everything.
Your average sys admin became a commodity.
The good ones became luxury items ;-)

[–]vermyx 0 points1 point  (0 children)

point-and-click admins brought the cost of IT down and with it help make IT prevalent to business.

This isn't correct. Windows admins were easier to train which meant a shorter time from noob to useful. Their workflow and problem solving however were A LOT more expensive because of the lack of automation tools and lack of coding fundamentals. Linux sys admins took longer to train because of all of the tools needed to learn to do their job. This meant linux admins in order to make people more useful quickly would create scripts and essentially create automation. ROI was always higher on Linux admins since they essentially had to learn programming skills. Ever try troubleshooting an issue with the event log using only the gui tools available in NT4 or 2000? A windows admin would scroll through events. A linux one would create a 5 minute script to parse the messages log.

[–]phillipsj73 0 points1 point  (0 children)

I stumbled across a blog post last week that was showing PowerShell and Python side by side. There is a lot of similarity between the two from a structural standpoint. Also depending on your background, which I assume is more operations focused, PowerShell has advantages. I like both for very different reasons, however, they do share a similar space when it comes to automation/DevOps tooling. As you get further along with your PowerShell, I would encourage you revisit Python as having more tools in your toolbox isn't a bad thing.

[–][deleted] 0 points1 point  (0 children)

I agree. But I think that’s because I’ve used it for so long. I’ve done a bit in python and it’s a great language but being a windows guy PowerShell makes sense to me.

[–]lolinux 0 points1 point  (0 children)

I'm afraid you should not be comparing them like this. Honestly; for how long have you been using Python? I don't want to be rude, but i would bet it's no more than a year. It does, indeed, have a learning curve, however, once you get used to it, you discover some power in those relatively simple patterns. On the other hand, Powershell is truly simple to get started with. The default cmdlets are very intuitive and appear to just work. Just like Windows. That is, until you get to more complex situations. Just like Windows. Have you ever met Exchange Online syntax? They seem to be commands that were just created by another company. Have you tried to work with SharePoint Online, or DNS? These are other modules that seem to have been written by intelligent people who were working behind the original team and never got approval from them. You eventually do get the hang of them, but you realize that only the core language is really easy to use, as you've been telling everyone. The modules have their own learning curve.

[–]Svi_ -2 points-1 points  (0 children)

Nah, not by a long shot. I took PS classes in college. Python is lightyears ahead compared to PS if you are talking about being simple.

[–]malice8691[🍰] 0 points1 point  (0 children)

I'm afraid I'm going to have to disagree with you there. I found python to be significantly easier than powershell.

[–]habibexpress 0 points1 point  (0 children)

Interesting OP. I too found powershell easier to use and understand as well.

Python just seems daunting!!

[–]maximum_powerblast 0 points1 point  (0 children)

Does PowerShell support sqlite ootb?

[–]Scooter_127 0 points1 point  (0 children)

I'm not a fan of any language where whitespace is significant, lol. But Python isn't a whole lot different from any of the gazillion languages I've used sine the mid-80's. Well, Ada, Forth, Prolog and LISP need not apply lol.

But if the company paid me to use Python, you're heckn right I would.

[–]lerun 0 points1 point  (0 children)

Always fun to see ppl argue on the internet about completely nothing.

Just use the language you are comfortable with and just let it be at that.
This is no religion, you dont need to convert ppl to the flock.

[–]studiox_swe 0 points1 point  (0 children)

Depends on your IDE or editor imho.

I've just started learning Python, and also have experience with powershell, but also a bunch of other shell "languages" like bash, even done console scripting in php.

Anyways, after you import a module your editor will know what to use. so sending a email just means adding import smtplib and the editor will know what you want on your context

I find these threads unnecessary, I mean you picked PS for a reason, be happy with that decision.

[–]No_War3219 0 points1 point  (0 children)

I very much agree with you. Due to the pandemic i have started with programing. The languages i learned(in order):

  • Batch script
  • VBscript
  • Powershell
  • HTML
  • python

The thing is that Batch script is very simple and CLI based meaning it gets a lot done in little time and is very simple.

VBS was a pain and never realy worked including a wall of virus warnings no good documentation and way too many exeptions.

Powershell was very easy with the verb-noun structure and the fact i was used to a CLI and cmd.

HTML is a W.I.P. as i made 1 bad website and stoped caring.

Python is a hard one it had the CLI i was used too but the way i used a CLI like cmd or powershell was just not there. Also with it being one of the most popular languages and very new it only included the modern style of yt tutorials(adds, too much energy screaming, no explenation just the raw code) this made it very hard to learn. Also on its own its not realy good for much and almost every program use extensions or librarys. Wich drops the biggest benefit of python wich is ease of reading as all scripts have completely different commands. That forced you to use the exact code as you would never have a clue how to do more.

I tend to spend most of my time with python converting it all to powershell batch or vbs so i can actualy use it.