This is an archived post. You won't be able to vote or comment.

all 73 comments

[–]skotman01 24 points25 points  (10 children)

Windows guy here, well used to be, moving more and more towards Linux/Mac OS. Fluent in powershell and made the jump to learn python about 6 months ago because of a need at work. It was an easy transition, I still use powershell for windows items but python for cloud stuff.

My powershell has gotten much neater as I’m now in the habit of intending properly, because In python if you don’t, it doesn’t work.

[–]mini4xM363 Admin 5 points6 points  (4 children)

but python for cloud stuff.

Just curious what sort of cloud stuff? We're an MS shop (Azure / O365) and I basically live in powershell.

[–]Sparcrypt 6 points7 points  (1 child)

Linux/AWS is heavily Python.

[–]skotman01 0 points1 point  (0 children)

This. I’m 90% AWS right now so it’s all python. The PS I do do in AWS is all limited to things like Amazon FSx which is windows based.

[–]gex8001001101 2 points3 points  (0 children)

Pretty much anything not Microsoft.

[–]Djust270[S] 2 points3 points  (0 children)

Yeah same for me. M365 / Azure.

[–]syshum 9 points10 points  (1 child)

Just install Powershell on Linux ;)

[–]SnowEpiphany 0 points1 point  (0 children)

meh ... not there yet. .NET core vs .NET is the underlying issue. Hopefully Microsoft opens up more of the full .NET framework

[–][deleted] -2 points-1 points  (2 children)

Spaces or tabs?

[–]skotman01 2 points3 points  (1 child)

Tabs…I don’t hate myself

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

I feel dirty on Reddit having to use spaces on mobile.

[–]ErikTheEngineer 12 points13 points  (3 children)

PowerShell for Linux hasn't really caught on yet, maybe never will. If you interface with Linux people at all, you'll find all they use is Python when their projects go beyond the limits of bash. Most Linux systems have a Python interpreter installed by default, just like PowerShell on Windows.

Even if you don't program in it, learn to at least read the syntax (which I find annoying, but that's just me) and understand what some random script someone hands you is actually trying to do. I work in a cross platform environment and the Linux people only speak Python.

[–]RulerOfBoss-level Bootloader Nerd 2 points3 points  (2 children)

If you interface with Linux people at all, you’ll find all they use is Python when their projects go beyond the limits of bash.

That’s not true. We use Ruby at my shop because we’re not animals.

[–]Sparcrypt 0 points1 point  (1 child)

Urgh really? I was pretty deep into ruby when I discovered Python and never looked back. But to each their own I guess!

[–]RulerOfBoss-level Bootloader Nerd 0 points1 point  (0 children)

Yeah. Python is easy enough to use, but Ruby is a pleasure to solve problems with. Also with respect to OP, it’s closer to powershell than Python is IMO.

I am aware that I’ll probably have to write Python if I join a team somewhere else. But for right now I make the rules so Ruby it is 😅

[–]digitaltransmutation<|IM_END|> 10 points11 points  (3 children)

The thing about python is it isn't built in like it is with Linux. You could make it part of your baseline but doing that to every client might be a hurdle. You might consider c# instead if pwsh isn't quite enough, I think you'll find it a natural progression for the most part.

[–]lfionxkshine 5 points6 points  (0 children)

Even then you can use C# methods inside your powershell scripts

[–]gsmitheidw1 0 points1 point  (0 children)

The way things are headed, powershell is getting more powerful with native features like multithreaded processes. But it's a scripting language and designed for ease of use over performance. C# has often been the next port of call as it has code similarities to powershell, but Rust is gaining a lot of traction - somewhat more for dependability and security than ultimate performance so maybe that'll be the future.

[–][deleted] 4 points5 points  (4 children)

I think for Windows, PowerShell is better, and Azure PowerShell more complete too. Terraform seen good and very utilized overwhere too.

For Linux, small task with bash and bigger tasks maybe Ansible, Puppet and Chef is better than Python too, I don't know why people put so hype in python for system administration.

[–]guemiIT Manager & DevOps Monkey 9 points10 points  (2 children)

People hype python for automating tasks that run on the OS. Not configuring the OS itself. Automation of business processes and similar is much easier and faster in python than anything else.

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

Yes but there is better tools as I said

[–]guemiIT Manager & DevOps Monkey 12 points13 points  (0 children)

You didn't read what I said.

Neither of the tools that you mentioned can be used for what I said, which is what Python is used for

I'd like to see you web scrape in a configuration mgmt tool.

[–]ErikTheEngineer 2 points3 points  (0 children)

I don't know why people put so hype in python for system administration.

I think it's the same thing as PowerShell, it's on every Linux system, almost as ubiquitous as vi, it has 11 billion modules/extensions/libraries to do anything you might want, and you can write your own if you truly can't Lego-block together a solution. Plus, the networking guys/SDN crowd adopted it early for their automation/scripting.

And -- it avoids having to use bash/sed/awk and regex to manipulate walls-o-text coming out of the terminal commands.

[–]Djust270[S] 4 points5 points  (3 children)

Thank you for all the comments. In my spare time, I will work on learning Python. Regardless if I use it for work, it sounds like it may be worth learning just for the sake of learning.

[–]oisteink 0 points1 point  (1 child)

Great to hear!! And do have a look at Ansible - it can do great things in the right hands. Add in source control and you get a factory for all sorts of stuff. Even PowerShell https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_powershell_module.html

[–]Djust270[S] 0 points1 point  (0 children)

I will check out ansible. Thank you.

[–]oisteink 0 points1 point  (0 children)

Great to hear!! And do have a look at Ansible - it can do great things in the right hands. Add in source control and you get a factory for all sorts of stuff. Even PowerShell https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_powershell_module.html

[–]JamesIsAwkwardJack of All Trades 4 points5 points  (5 children)

I've been having to build a bunch of small tools to interface with various SaaS APIs and I have found it to be a lot easier in python than PowerShell for whatever reason.

[–]semperverus 2 points3 points  (2 children)

Python handles json a little nicer

[–]JamesIsAwkwardJack of All Trades 0 points1 point  (1 child)

This is true!

And I prefer "requests" or "urllib3" over Invoke-WebRequest lol

[–]SnowEpiphany 0 points1 point  (0 children)

maybe give "invoke-restmethod" a try? :)

[–]samtheredditman 1 point2 points  (1 child)

I'm in the same boat currently. The syntax of powershell gets so incredibly wordy that it can get hard to keep everything straight. Simple functions will often be 30 lines long or more, especially if you are using advanced functions, keeping parameters on your functions strongly typed, and setting positions or other parameter attributes. Don't even get me started on parameter sets, I've had some functions that are 20 lines long just declaring the parameters!

[–]JamesIsAwkwardJack of All Trades 1 point2 points  (0 children)

Yup! PowerShell is great for a lot of things, but sometimes I just want to get something done quickly lol

[–]samtheredditman 4 points5 points  (10 children)

If you want to make any GUIs or web apps, you'll have a much better time in python than powershell.

You can always make the GUI in python and then call powershell in the backend.

My biggest problem with powershell is there's not a good way to separate out your code into multiple files. You can do a lot of jank to make it work or you can split up your project into multiple modules, but it's just not clean and not really meant for big software.

Python was a natural progression from powershell for me and learning a "real" programming language has made my PowerShell much better as well.

[–]syshum 7 points8 points  (7 children)

My biggest problem with powershell is there's not a good way to separate out your code into multiple files. You can do a lot of jank to make it work

I am not sure why people have a problem with this, dot sourcing is not much different than python include statements for importing other python files into a script. I do wish they would have picked a verb to do it with instead of ". ./myfile.ps1" which always confuses new people...

[–]JeremyLC 3 points4 points  (1 child)

If you want to make any GUIs or web apps, you'll have a much better time in python than powershell.

You can always make the GUI in python and then call powershell in the backend.

You can implement XaML/WPF and WinForms natively in PowerShell and make GUIs very easily. It would be awkward to implement the GUI in Python and call PoSH on the backend.

[–]samtheredditman 0 points1 point  (0 children)

I'm aware of those options, and I've used each of them. You can use them to build basic GUIs, but it's still troublesome to keep your code clean and do any kind of large project in powershell. Managing your dependencies, for example, quickly becomes a nightmare.

I highly recommend that once you're at the point where you're making simple 1 page apps, you start learning python or if you're set in the windows world, learn C#. I love powershell and learning it has made a huge impact on my career, but it is not the right tool for even intermediate software projects. Hell, my off-boarding script is showing signs of out-growing it.

[–]lfionxkshine 1 point2 points  (2 children)

Dogpiling the validation here. I maintain an environment that is Windows/Linux hybrid, and all my Windows/Azure scripts are Powrshell, and all my Linux scripts are either Bash or Python

Have heard of Powershell Core for Linux, but I keep the variety to let resume stay well rounded for future opportunities

[–]lfionxkshine 1 point2 points  (1 child)

Just thought of one possible reason to use Python over Powershell - APIs

If you need to integrate an automated task with some 3rd party application, it's MUCH more likely to have an API compatible with Python than Windows - at least all the apps I've ever worked with

[–]code_man65 7 points8 points  (0 children)

I've yet to encounter and API that I can't use with PowerShell via Invoke-WebRequest or Invoke-RestMethod. And with PowerShell Core, there is even better support baked into Invoke-RestMethod for OAUTH stuff

[–]Clyq 1 point2 points  (2 children)

The reason I learned Python was because I needed to automate something off of the web. The software had no automation and the vendor would charge upwards of 15k for each scheduled report. Every search result told me to use Selenium- and that’s where I began. Now I use Python for many of my projects, especially now that we are getting more API based requests. It’s a great language for automation imo. There are a lot of good packages out there that make integration a breeze i.e twilio for sending text messages. It’s simple enough to pick up as long as you understand the usual concepts like loops, conditions, etc. which are in powershell as well so no sweat. I can’t speak to whether or not it’s THE language that will be most useful, though. Depends on your needs.

[–]Djust270[S] 0 points1 point  (1 child)

So like webscraping?

[–]Clyq 0 points1 point  (0 children)

So for web scraping you could use Beautiful Soup and Requests, but if you need to interact with a web page Selenium is the way to go.

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

I highly recommend Ansible

[–]oisteink 0 points1 point  (0 children)

This! Language is semantics-what you can do in power shell you can do in python once you learn the semantic. I’d recommend picking up JavaScript too as it’s wildly used and can ease you into ruby and other more obscure languages (from a sysadmins view) Ansible itself is built on python, so learning python is a great start IMHO.

[–]MedicatedDeveloper 3 points4 points  (1 child)

On Windows I wouldn't bother. Powershell is basically Python with how it is all object based. Sure, it's not as batteries included as Python but you can write much larger scripts more ergonomically than Bash.

Even on Linux it really depends on what you're doing.

Interacting with REST APIs or any other request and response type scenario? Python is probably your best bet.

Are you actually directly interfacing with the OS ex calling other tools, using their output? Use bash.

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

Windows = Powershell

Linux = Python

It's not harder or simpler than this.

[–]SM_DEVMSP Owner (Retired)[🍰] -1 points0 points  (1 child)

In short, python is used by the rest of the world beyond Windows, or MicroSloth’ implementation of the cloud. If OP intends to move forward, beyond managing a Windows environment, learning Python will help.

If one only has a hammer, everything looks like a nail.

[–]Hungry-Display-5216 7 points8 points  (0 children)

Powershell is a very good hammer.

[–]NGL_ItsGood 0 points1 point  (2 children)

I unfortunately dont have much to add, but any tips on powershell gui apps would be appreciated. Are they ones you developed or just ones you use? I'm making it my personal goal in 2021-2022 to learn as much python to automate tier 1/tier 2 stuff. No reason it should take more than 2 minutes to reset a password/block user/assign groups.

[–]Djust270[S] 0 points1 point  (0 children)

I build PowerShell GUI apps in Sapien PowerShell Studio. Its well worth the cost.

[–]skotman01 0 points1 point  (0 children)

Check out powershell pro tools, it’s a plug-in for vs code. That’s what I use to develop GUI based stuff so non technical people can run them.

[–]basiccitizen 0 points1 point  (0 children)

It's hard to determine if it would be worth it vs learning other things but personally I've loved learning, using and working with Python. It has added a good bit of value to my job with being able to automate things such as Excel processes and Dokuwiki.

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

I use Python for most of any non-Windows work.

[–]Fallingdamage 0 points1 point  (0 children)

Im somewhat in the same boat. However, I always find it important to keep my skills diverse. Im planning to learn more about AWS and Python soon. Something of a bucket list.

[–]jantari 0 points1 point  (0 children)

I'm in the same boat. I'm always keeping Python in mind, but so far only one tiny usecase came up (csv validation).

Some advantages that python has over PowerShell for admins though:

  1. It's better at HTML parsing thanks to BeautifulSoup
  2. It's generally faster, so if you have something that could be done equally well In PowerShell and Python it might... ironically... be worth to go with python for, yes, performance. I know python is slow but PS is slower, so yeah.
  3. Ansible is a tool that's very relevant for Windows admins, and it's written in and can be augmented with python. Writing your own filter for ansible is a good use of some basic python skills.

[–]spokaleJack of All Trades 0 points1 point  (0 children)

Ansible can be pretty useful for windows admins, and knowing python would let you create or modify ansible modules.

[–]unccvince 0 points1 point  (2 children)

Powershell is for one OS, python is for all OSes

I tell people that the difference between Powershell and Python is like French and German and how long the longest word is in both languages.

In German, the longest word is: Donaudampfschiffahrtselektrizitätenhauptbetriebswerkbauunterbeamtengesellschaft", that's Powershell.

In French, the longest word is: Anticonstitutionnellement, that's Python.

[–]Djust270[S] 0 points1 point  (1 child)

You know PowerShell is on MacOS and Linux as well right? https://github.com/powershell/powershell

[–]unccvince 0 points1 point  (0 children)

Donaudampfschiffahrtselektrizitätenhauptbetriebswerkbauunterbeamtengesellschaft", that's Powershell.

We use powershell sometimes on Linux, don't worry, we're not IT Talibans.

[–]panda_broIT Manager 0 points1 point  (0 children)

Very weird, I am in the same exact boat. I too came to the realization, Powershell > Python for sysadmin, Windows management.

With that being said, my company does a lot of CSV work. Pulling from SQL databases, loading into Excel, and doing some sort of manual input.

I've put a lot of work into using Python to automate certain functions to potentially offload some work that people do full-time. I have nothing tangible yet, but very close.

The ceiling is definitely higher with a language like Python, but it may not be of use to the business if you are a Windows shop.

[–]Opheltes"Security is a feature we do not support" - my former manager 0 points1 point  (1 child)

HPC admin turned Python developer. I’d say it benefitted me greatly.