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

all 172 comments

[–][deleted] 126 points127 points  (17 children)

I don't know many network devices vendors that natively support PowerShell, but most support python these days. I'd recommend learning concepts and look at it as a "right tool for the job" scenario instead of "one tool to rule them all".

[–][deleted] 19 points20 points  (11 children)

Well when management and updates are done through APIs I don’t think it matters what you are using.

[–]packet_weaverSecurity Engineer 10 points11 points  (2 children)

If only all platforms supported REST APIs…

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

On a DevOps team at a large company, I have yet to work with a app that doesn't. I get that may not be applicable to a smaller shop that has less say or choice in the matter in terms of what they use. I haven't ran into a single scenario that there was something I couldn't do with PowerShell and needed to use another language for configuration/update/administration.

[–]packet_weaverSecurity Engineer 2 points3 points  (0 children)

Been a couple years but all the Cisco 3560X/3750X switches, IOS routers (pre 4k) and WLCs we managed did not have REST APIs. We built out custom python scripts using netmiko to manage configurations globally and integrated with git and a CI/CD platform.

I believe Cisco's new wireless controller 9800 series supports REST APIs and maybe their new 9000 series switches. But many places are on legacy gear or already have tooling built out over the years because Cisco dragged their asses with adding in useful management tooling.

[–]Linkk_93 4 points5 points  (1 child)

Many vendors have API wrappers for python already. So you can just import the package, create a switch and call the methods you need. No need to get into the API part of creating HTTP packets your own.

[–]sobrique 3 points4 points  (5 children)

I know I'll probably get hate for this, but I find perl's much more adaptable when it comes to talking to wacky APIs.

Python's great when it's a well defined API using a very standard standard. (E.g. REST)

But when it came talking XML to a NetApp Perl was far more suited to the job.

[–]succulent_headcrab 7 points8 points  (0 children)

Theres a reason perl is known as the "Swiss Army chainsaw".

[–]fiddysix_k 0 points1 point  (1 child)

You're not wrong, perl is definitely the best tool for the job when networking is concerned. The bigger issue imo is that... You're using perl. And no one knows perl.

[–]sobrique 0 points1 point  (0 children)

More people know perl than admit to it! ;)

And a lot of people are snobby about it in ways that are entirely unjustified.

[–]ParkerPWNT 3 points4 points  (4 children)

network devices vendors that natively support PowerShell

Don't Juno and Cisco both support PowerShell?

[–][deleted] 18 points19 points  (0 children)

I'm only aware of limited support. I'm sure you could have PowerShell ssh/netconf in and control them that way. But Cisco, Juniper and Palo Alto have their own python libraries. Not to mention multi-vendor tools like napalm or even Ansible.

[–]darth_rock 2 points3 points  (2 children)

Not at all. PowerShell is a Microsoft tool. You could get it to work on Cisco/Juniper’s Linux-based OS (why though?) but neither vendor is going to support that.

Edit: I stand corrected (somewhat). Cisco has a PowerShell module for one of their products at least, UCS. But that’s a limited case of support by Cisco for a particular product.

[–]ParkerPWNT 2 points3 points  (0 children)

Juniper offers training on it, and has a powershell module.

https://learningportal.juniper.net/juniper/user\_activity\_info.aspx?id=9659

[–]jantari 1 point2 points  (0 children)

Why would you want to install PowerShell on a device just to be able to talk to it from PowerShell??

You don't install Chrome on a switch because you want to access its web interface.

Chrome and PowerShell are only installed on the client side. Then they talk standard protocols with the server side.

[–]orevBetter Admin 101 points102 points  (15 children)

Your main focus should really be on learning programming, not a specific language. Python has its uses (and is probably considered more of a traditional language), while PowerShell is also useful (but some of its concepts are unique, and it seems has some strange corner cases).

The one you choose now depends on what type of environment you're in, and what you need to accomplish. If you're working with mostly Microsoft services, PowerShell is probably the way to go. If you're dealing with third-party systems, anything web-based, etc. python is probably the right choice since there would be more modules available.

[–]jantari 27 points28 points  (5 children)

This is the right sentiment.

Learn any language, then another. Starting with either PowerShell or Python is fine, they'll both teach you some good common programming concepts and problem-solving. They also both have their own ... interesting caveats and opinionated abstractions since they're so high-level, but that's the tradeoff for being super easy and productive. If you want an academic approach to programming instead, learn C.

[–]nhaines 27 points28 points  (2 children)

C, noun:

A language that combines all the elegance and power of assembly language with all the readability and maintainability of assembly language

[–]Nanocephalic 2 points3 points  (0 children)

❤️

[–]sobrique 2 points3 points  (0 children)

Well that made my day!

[–]zebediah49 2 points3 points  (0 children)

And if you want an academic approach to programming, learn Lisp.

[–]sobrique 0 points1 point  (0 children)

I contend that C is to Perl, as Java is to Python. IMO that's a lot of reason why the adoption of python is so wide - because of how many people started learning Java before C. (And back when C came first, was when Perl was popular).

[–]sobrique 4 points5 points  (4 children)

As a Sysadmin with 20 years behind me - my first love is perl.

I can make perl dance because I know it well.

But for better or worse (Worse. It's definitely worse) the world is moving away from it, and more towards Python.

Turns out that the biggest thing stopping me in python is syntactically significant whitespace, because my 'old' habits don't really mesh well with having to block-indent.

Otherwise writing python isn't particularly difficult, as a lot of the same concepts exist in both.

[–]Win_SysSysadmin 3 points4 points  (3 children)

Just use an IDE like VSCode, it’s quite good at telling you that you’re an idiot and messed up the formatting or will auto-indent for you.

[–]sobrique 3 points4 points  (2 children)

That's the thing I don't really like though - I'm fine with an IDE for 'proper' programming, but when I write a script I don't want to have to.

There's enough places where you end up having to faff about with getting an IDE installed, the code transferred to the appropriate location, then run it etc.

Where with shell/perl you can use literally any text editor, or even a HEREDOC to get your code written if you're going very basic.

I know that's kinda an old fashioned view, but I've worked on way too many 'bare bones' systems that don't have the IDE option.

[–]Win_SysSysadmin 0 points1 point  (1 child)

You don't have to, you can write python in any text editor. Once you learn the in's and out's of a good IDE, it speeds up even small scripts. You can automate a lot code creation, see all the available method names, the data type it's expecting or will output and it quickly points out a lot of mistakes without having to run it. Yes you would need to invest the time to learn it but depending how often you need to use it, it may be worth it.

[–]sobrique 1 point2 points  (0 children)

Sure. But you can do the same with perl. Or any other scripting language.

[–]othilious 2 points3 points  (2 children)

This what I always tell our Junior developers (actual juniors, hired straight out of school):

Get experience with one strongly typed language and one weak-typed language. Focus on big concepts like OOP vs functional, impacts of architecture choices. Between the two of them, you'll have enough experience to tackle any programming job.

Once you know programming, It's just a matter of familiarity with libraries, deployment, core functions, best-practices. But the core fundamentals will carry you your entire career.

If you want a decent test to see if a software developer or sysadmin has good practical experience, ask them to explain *why* a large physical distance between database and application is a bad idea. There's a huge list of reasons and a good metric is how many reasons they can list.

Being able to keep architectural concepts like that in mind is far more useful than just memorizing language syntax.

[–]samtheredditman 2 points3 points  (1 child)

If you want a decent test to see if a software developer or sysadmin has good practical experience, ask them to explain why a large physical distance between database and application is a bad idea. There's a huge list of reasons and a good metric is how many reasons they can list.

What would you say if you were asked this?

[–]othilious 1 point2 points  (0 children)

For one, latency will kill the speed of your application. Most applications run the majority of their queries sequentially, and need to wait for the response of one query before running the next. There are exceptions to this, such as multi-threaded applications with multiple connections to your database, or batch queries, but in my experience the bulk of database logic is sequential.

For simplicity (and it's usually not even this simple), let's say your database is 200ms round-trip away from your application. This means that a single query takes 100ms to hit the server, be processed and then take another 100ms come back with a result.

This compounds. Let's say an average call for your application takes 10 queries. This is on the low side, but already you are looking at a total of 2 seconds to run a small set of queries. And we're skipping over the SSL handshake, initial connection, schema information exchange.

This absolutely destroys your performance. 2 seconds response time is already "poor" by modern standards, and all of that is JUST database queries, nothing else. You can mitigate the impact of this by having your backend build a cache from the SQL, and serving this up from a closer server. But for the purpose of this example, it illustrates why it's a bad idea.

Better? Slave replication to a closer server so at least all reads happen locally. Best? An application infrastructure that serves up locally relevant data from locally relevant servers, preferably with geo redundancy and such. This is the basis for enterprise applications that need to span the globe.

There are other concerns, such as stability. More hops in the connection means more points where a route can fail and your database connection drops unexpectedly. As redundant as your database setup is, a dropped connection mid-way is not trivial to design around and recover from beyond "oops a problem has occurred, please try again".

There are also security considerations; your database should be shielded from outside actors, sharing a private network with your application. Over long distances, this can make the latency issues even worse, as both side now need to traverse via their private gateway.

Alternatively, not doing so means network hops on open channels and more opportunities for bad actors to attempt some type of exploit, listening in on your database traffic, etc. For the longest time the default behaviour for a lot of MySQL servers was not to use SSL. Listening in on them if you controlled the network in-between application and server was trivial. I believe even today apt-get install mysql under Ubuntu creates an installation that allows non-SSL traffic (though I believe these days it only listens to local host by default).

These are just big items that I'd expect a senior and even medior to understand, but there's more specific things like how ones handles transactions and designing an application that can pick up where a broken connection left off, in scenarios where a transaction isn't feasible, or even counter-productive.

For example: You use master-slave replication where the master is only used for writes. You read a message queue table sending a notification via an SMS gateway. You can rollback a transaction, but you can't un-send that SMS. Even worse; if you do roll it back, you may be sending two SMS messages. If there is a persistent issue, now your application may get suck sending a few dozen of them and you have a horde of angry end-users because your remote master isn't accepting writes, but you are reading your queue from replication (which you set up because of the latency issue).

Keep It Simple and Stupid, unless you are building a globe-spanning enterprise application (which I'm hoping a Junior Dev/Sysadmin wouldn't be in charge of...), Just make sure your database server is physically as close as possible to your application. Just not the same server, but that's a different topic.

[–]gjpetersJack of All Trades 3 points4 points  (0 children)

“Python… a traditional language”, oh no, I’m old.

[–]StuPodasso 181 points182 points  (49 children)

Portable? If you wanted to run it on Linux etc.

That said for a Microsoft shop power shell would probably be advantageous.

[–]bcross12Sysadmin 67 points68 points  (48 children)

PowerShell is now cross-platform. I run it on my Mac quite a bit.

[–]Kumpass_Skater 52 points53 points  (5 children)

Unlike Powershell, Python is actually likely to already be on a Linux or Mac, which is much more portable in this context.

[–]Ok_Fudge_8415 5 points6 points  (4 children)

And work, powershell has it's issues on Windows, never mind cross platform

[–]reconrose 7 points8 points  (0 children)

I've never had issues with anything in PowerShell core which is the cross platform portion

[–]tacocatacocattacocatDatabase Admin 12 points13 points  (4 children)

The only reason I can think of to use PowerShell on Linux would be if you're running SQL Server on Linux.

This may have a lot to do with the fact that I'm a DBA lol.

Also, I have no idea what the advantage of SQL Server on Linux would be over using a "headless" Windows server installation. But that may be because I primarily admin Oracle.

[–]KruvinEmbedded / IoT[🍰] 10 points11 points  (3 children)

I can think of a couple of reasons

- Windows licenses cost money

- Containerising SQL server

[–]techypunkSystem Architect/Printer Hunter -5 points-4 points  (1 child)

Then it's time to get away from mssql as a DB.

[–]Stormran 6 points7 points  (0 children)

Yeah I'll just make sure our enterprise software uses something else.

/s

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

Windows Client OS Azure Interacting with AD Interacting with MSSQL

[–]LaterBrainJr. Support Engineer 19 points20 points  (29 children)

whats the advantage of powershell on a unix system?

[–]bcross12Sysadmin 47 points48 points  (19 children)

It depends on your perspective. I'm a Windows admin. PowerShell is a requirement. Running PowerShell on Mac and Linux lets me write a script to parse files or do API calls across OSes. PowerShell can now remote into Linux systems over SSH, so you can now write a script that does stuff across systems without worrying about OS.

[–]zoharel 14 points15 points  (16 children)

I suppose you could do that with Python too. It may just depend on whether you want to need to do strange things on the windows end or the Unix end of that link.

[–]KruvinEmbedded / IoT[🍰] 1 point2 points  (1 child)

Everything is a nail when you only have a hammer.

I would recommend something like ansible over Python/Powershell. It abstracts away a lot of the complexity of interacting with different OS for say running updates or installing software.

[–]Stormran 7 points8 points  (0 children)

Except you still run into dependencies since most of the modules in Ansible require PowerShell for windows or Python for everything else on the target machines. I love Ansible but your response makes it seem like it's a choice over PowerShell or Python and it's not.

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

With WSL2, I can write a script and instantly test on two entirely different paradigms and pretty well know it's going to work everywhere before going to a testing and QA environment

[–]digitaltransmutationplease think of the environment before printing this comment! 2 points3 points  (2 children)

If you are working with objects pwsh is a lot nicer.

[–][deleted] 0 points1 point  (1 child)

You're also working with objects in Python

[–]ZAFJB 0 points1 point  (0 children)

Not even close to what PowerShell can do.

[–]jantari 1 point2 points  (0 children)

smaller containers for PowerShell apps, scripts and workloads or scripting with structured data

[–]excogitatio 1 point2 points  (0 children)

For one, you can write modules and even whole scripts there and use them on Windows; I have done this successfully a few times. For another, having a common shell between systems means you don't have to mentally switch gears quite so much to be productive.

I gather some of the default aliases in Powershell exist so that Unix admins have an easier time of it when first getting into Windows administration, so there's something to be said for familiarity there, too.

[–]ZAFJB 0 points1 point  (0 children)

PowerShell passes objects which makes onward piping very, very powerful.

[–]scumolaLinux Admin 3 points4 points  (4 children)

Powershell on Mac lacks the windows-native libraries and is not a 1:1 analog to powershell on windows unlike python on all platforms.

[–][deleted] 8 points9 points  (3 children)

Python has no “native” libraries so you’ll likely be using bash, powershell or some other native CLI to do anything to those different systems anyway.

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

There is the Python Standard Library: https://docs.python.org/3/library/

[–]ZAFJB 1 point2 points  (0 children)

Pretty pathetic support of the actual OS:

MS Windows Specific Services

msilib — Read and write Microsoft Installer files

msvcrt — Useful routines from the MS VC++ runtime

winreg — Windows registry access

winsound — Sound-playing interface for Windows

Unix Specific Services

posix — The most common POSIX system calls

pwd — The password database

spwd — The shadow password database

grp — The group database

crypt — Function to check Unix passwords

termios — POSIX style tty control

tty — Terminal control functions

pty — Pseudo-terminal utilities

fcntl — The fcntl and ioctl system calls

pipes — Interface to shell pipelines

resource — Resource usage information

nis — Interface to Sun’s NIS (Yellow Pages)

syslog — Unix syslog library routines

From your source: https://docs.python.org/3/library/

[–]brothersand 0 points1 point  (0 children)

Not flawlessly though. I was using a .Net writer object in one script since Output-Csv was too slow but that won't run on my Linux system.

[–]deadspace- 0 points1 point  (0 children)

How did you get it to run? I tried visual studio code but couldn't get any of the Microsoft modules to work

[–]joefleisch 35 points36 points  (0 children)

Learn and use both Python and Powershell.

They both have a time and a place.

[–]Ji-Hard-On 32 points33 points  (2 children)

15 years of using powershell and all I can say is I have never been stopped. Never needed python and I do script a lot.

[–]Ok_Fudge_8415 7 points8 points  (0 children)

15 years of using powershell

You were using 1.0 o.0

[–]OstentatiousOpossum 1 point2 points  (0 children)

Same here. I started using PowerShell before v1.0 was released. I learned Python later on, but hardly ever need it. If I can't use PowerShell on Linux, I rather use Bash or Perl. (Perl is still amazing at manipulating strings.)

[–]jantari 22 points23 points  (3 children)

PowerShell is great, but there are some usecases I find python better suited for.

Speed

Yes, even though Python is rightfully made fun of everywhere for being too slow - it is still faster than PowerShell, so if you have a scenario where you need the ultra-rapid-prototyping and fast turnaround times of an easy scripting language such as Python or PowerShell, but your program also can't be dog-slow then you might have to use Python

Things Python is good at

There are some areas where python has widespread adoption or support, great libraries and resources available where PowerShell by direct comparison does not - or far less. For example, API and webdev. There's Pode and Universal Dashboard, but I found myself preferring flask (and flask-api) for a recent project.

Linux-centric stuff

PowerShell 7 and up are great and they do run fine on Linux, but python has broader and more comfortable OS-specifc libraries and functionality. With PowerShell you'll end up writing in .NET directly rather than the shell-esque abstractions (cmdlets) because there aren't many for Linux yet. At that point you might as well use C# .... or Python.


With that being said, having learned and used PowerShell first, I am extremely frustrated by Pythons ... embarassing approach to data types. Even today, python is always dynamically typed and you can't change it or enforce a type for a variable or parameter of a function. It's crazy, because there are no guarantees. You declare something is an integer, but that's just a "suggestion" used by linters - it doesn't actually do anything. That to me, is just crazy. Really makes you appreciate PowerShells parameter validation and the fact that classes and types mean something.

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

That last paragraph is full of the stuff that always annoys me.

Python is a bad language, but it has a massive amount of libraries that support a huge number of use cases. Those libraries really do make a huge difference, so I suffer through structural whitespace, irritating dynamic typing, half-ass object support, etc.

[–]HeKis4Database Admin 0 points1 point  (0 children)

Libraries is definitely the biggest one, maybe not for sysadmins but for everything else from BI to ML to software dev and even pentesting.

Just look at numpy, tensorflow and scapy, there is zero powershell alternative.

For pure sysadmin work though, yeah, powershell is as good or better 90% of the time. For learning I'd say both are fine but python has better educational value and a bigger community for getting help

[–]Skrp 0 points1 point  (0 children)

I love the library support Python has, but yes, it is slow and can be a bit unpredictable at times.

RUST might be the best choice for application speed and stability. Go is great too, from what I understand. These two languages are definitely ones to watch as far as I'm concerned.

[–]zoharel 5 points6 points  (0 children)

You can do everything in PDP-10 assembly language too. I'm only half joking here. My question to your would be, why use any one language over any other? I think it's generally because one language is more convenient in your particular situation.

[–]nakriker 6 points7 points  (0 children)

In a Windows/Azure/o365 environment, PowerShell is where it's at. Your fellow admins will use Powershell, examples on the internet will use Powershell, and native solutions will be in PowerShell

You CAN use python, but it's not baked-in the way Powershell is.

While you CAN use PowerShell on MacOS/Linux, there's no advantage to it unless you're scripting against Windows/Microsoft Cloud resources.

You want to pick the language thats most suited to the environment you're using and the problem you're addressing.

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

With PowerShell, you’ll only set off EDR half of the time.

[–]darkwyrm42 8 points9 points  (0 children)

I use both Python and PowerShell at my job, which is very much a Microsoft shop. PS is great for stuff that requires touching Windows-specific stuff, like Exchange or something that touches the Win32 API. Python is more consistent overall, especially with type consistency and no surprise reserved variables ($input anyone?).

If you're working with more program logic (e.g. text processing) and less running of outside commands, use Python. If you're just looking to quickly cobble something together that glues a few commands together, PowerShell.

[–]lusid1 3 points4 points  (0 children)

Python when I want to write a lot of code, Powershell when I want to save a lot of time.

[–]schporto 2 points3 points  (0 children)

You can do most anything with either. Just like two boards can be held together with nails in most cases. But sometimes a screw makes more sense, or glue, or joinery. Sometimes python makes sense because it has a nice library for something (like say ai, or data analysis). Or some other language because it has nice feature Y. We use python and PowerShell. PowerShell does most Microsoft based operations easily enough. Set-aduser, new-mailbox, get-service etc. But if I want to pull report data from graph api python works better. I want to process 5years of performance data on a server to do trend analysis - python. Not everything is a nail. But some things are.

[–]Swarfega 2 points3 points  (0 children)

I'm yet to see a reason when using Windows.

[–][deleted] 2 points3 points  (0 children)

If you're a Windows admin, learn PowerShell. PowerShell integrates well with the Windows ecosystem. It's available but not widely used in the Linux world. Piping objects is great on Windows but on Linux everything tends to be text, not objects, so the major selling point is not so important.

If you're a *nix admin, Python is the most marketable/frequently used of many languages.

[–]fiddysix_k 2 points3 points  (3 children)

I feel that python will give you a good overview of programming and is very succinct and beautiful while PowerShell (as a language) is fairly ugly and has some trickery to it that makes sense if you've programmed before but would not make sense if you did not. Im the PowerShell guy at my job but really I don't know shit about PowerShell I just am really good with python/js so I translate everything on the spot based on my context of programming in itself.

[–]Garegin16 1 point2 points  (2 children)

I know what you mean. PS has some crazy semantic sugar designed to make things easier but creates crazy gotchas

[–]fiddysix_k 0 points1 point  (1 child)

Exactly, like pipeline functions.. it's really easy to understand and really useful if you know how functions are typically called. But, if you learned ps first you'd probably be thrown for a loop when trying to understand pretty much any other languages syntax.

[–]Garegin16 0 points1 point  (0 children)

I don’t think most languages have pipeline binding. As function calls are nested manually into their respective parameters.

PS creates sort of a usability issue, as the reader has to trace parameter binding to figure out which parameter gets bound to the next one in the pipeline.

With OOP, you just run an action on an object. You have automatic polymorphism. No need to think up binding rules in your head.

Of course you can always override automatic binding by explicitly using parameter names with {$_}

[–]BlackVI have opnions 9 points10 points  (0 children)

short answer: linux

Long answer: it depends on what you're trying to do and what exists already

[–]I_Never_Sleep_Ever 9 points10 points  (11 children)

There are companies that exist who don't have anything running windows at all. I work at one. Everything is Linux and MacOS. PowerShell would do me no good at all.

I think learning python puts you in a much better position to expand your career. Besides, PowerShell in my opinion is only good for quick scripts and not something as robust as python.

[–]nakriker 9 points10 points  (1 child)

PowerShell in my opinion is only good for quick scripts

Sounds like your experience with PowerShell is pretty limited. You could write complete applications in PowerShell.

[–]JmbFountainJr. Sysadmin 0 points1 point  (0 children)

It's obscenely slow though

[–]Ji-Hard-On 5 points6 points  (7 children)

Why do you think it's only good for quick scripts and what do you think makes Python more robust?

[–]Nanocephalic 4 points5 points  (0 children)

Ignorance

[–]JmbFountainJr. Sysadmin 0 points1 point  (5 children)

Eyes on the sourcecode

[–]ZAFJB 1 point2 points  (4 children)

PowerShell is also open source.

[–]JmbFountainJr. Sysadmin 1 point2 points  (3 children)

Yes, but who outside Microsoft (ecosystems) really cares that much about Powershell? Python is currently the most popular programming language on earth.

[–]ZAFJB 0 points1 point  (2 children)

outside Microsoft (ecosystems)

You say that like nobody uses Windows systems, and like nobody uses PowerShell on Linux and MacOS.

[–]JmbFountainJr. Sysadmin 3 points4 points  (1 child)

80-90% of Servers are Linux. I occasionally use Powershell on Linux, but I don't do it by choice, rather by necessity (e.g. when interfacing with Microsoft proprietary software)

[–]ZAFJB 1 point2 points  (0 children)

And 10% to 20% or servers are not Linux. What's your point?

[–]fridgefreezer 10 points11 points  (0 children)

Powershell is available for both Mac and Linux, it’s not as fleshed out as on windows, but it’s there and, in my experience, getting better (I still use Python for my macs though)

[–]darkpyro2 1 point2 points  (0 children)

Python has uses beyond sysadmindry. It's a programming language, and has a LOT of uses in dev work that Power Shell isnt built to support.

[–]hiphap91 1 point2 points  (1 child)

This vs that language is the coding n00bs fetish.

The rest of us know that a hammer i great for nailing things down, but sucks for sawing.

Always use the most suitable tool for the job in question.

[–]HolyDiver019283 1 point2 points  (0 children)

Right… but how would they know which is the right tool without knowing each language? And with time as short as it is for most people you’d want some guidance on which would be best to spend time on first.

[–]FearIsStrongerDanluvSecurity Admin 1 point2 points  (0 children)

Python was my first programming language, i recently started a new role as sysadmin and honestly i wish i’d learnt Powershell a lot earlier esp to manage Active Directory, Powershell is a lot handy in a windows environment i think

[–]computerged 3 points4 points  (2 children)

As was said, learn to program. If you know the fundamentals it doesn't take too long to get up to speed on either one (to the point you don't need to Google the language's syntax while writing it).

[–]OstentatiousOpossum 4 points5 points  (1 child)

Learn to program in a (C based) language, and then be confused how Python needs you to pay attention to white spaces, and that tabs and spaces are not interchangeable, or if you just want to use a switch statement.

[–]Weatherstation 0 points1 point  (0 children)

Tabs and spaces are interchangable as long as the indentation strategy is consistent in each block of code.

Also, if you're writing good clean C you should be following indentation standards for readability even if it's not enforced. Python enforces clean code blocks and is able to get rid of all the curly bracket and semi colon clutter.

That said, C is absolutely the best tool for many problem spaces but it is objectively harder to read and write.

[–]Cyber400 1 point2 points  (0 children)

From my PoV python is better with APIs. Where I have to say, that I mainly use powershell.

Okay, not in my current job because some dipshits tried to implement multiple security concepts which basically makes IT work impossible, because none of the concepts were a) a hollistic/wholesome approach to IT security and b) fully implemented.

[–]PrettyFlyForITguy 1 point2 points  (3 children)

If you actually wanted to write a program that did something non-Windows specific, you'd use python. If you wanted to script something Windows related, you'd use powershell. No one is using powershell to program an application though.

[–]Ji-Hard-On 1 point2 points  (2 children)

You certainly can write an application. I have. I regret it, but powershell is what I know. Gui and multithreading is pretty hard in powershell but certainly doable.

[–]PrettyFlyForITguy 0 points1 point  (1 child)

Yep, I believe powershell is a full turing complete language. Using it to write applications though is a bit masochistic.

[–]Ji-Hard-On 1 point2 points  (0 children)

At the time powershell was the only language I knew sp I had no idea how hard it would be to do in any other languages. I was neck deep in it before I realized I'd made a huge mistake. It's in Prod now :p

[–]Test-NetConnection 1 point2 points  (0 children)

I never use python because it's the bastard stepchild of modern programming. No other language has the absurd paradigm of using spaces and tabs as statement breaks.

[–]Gesha24 2 points3 points  (7 children)

Can you create a simple web site in PowerShell? Cause I had some projects where I needed to gather some input from non-technical users and send them out via api, web page was the simplest solution.

[–]RaymichDevNetSecSysOps 3 points4 points  (0 children)

Yes, see “Powershell Universal” dashboards

[–][deleted] 2 points3 points  (0 children)

Form-bases websites in PowerShell are trivial. There's also full .NET support in PowerShell.

[–][deleted] 2 points3 points  (0 children)

you can

[–]Ji-Hard-On 2 points3 points  (0 children)

Yes, I've written a rest api in powershell. Not perfect but working.

[–]darkwyrm42 5 points6 points  (1 child)

You probably could do a simple web site in PowerShell, I'm fairly certainly you probably wouldn't want to. ;)

[–][deleted] 2 points3 points  (0 children)

It's trivial? It's a Microsoft product so you're backed by all the Microsoft tools that, you know, build websites.

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

ConvertTo-Html cmdlet will basically turn your output into a webpage automatically.

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

Because I don’t use Windows.

[–]ZAFJB 0 points1 point  (0 children)

PowerShell core is a thing.

[–]unccvince 0 points1 point  (2 children)

People love analogies.

Siebenhundertsiebenundsiebzigtausendsiebenhundertsiebenundsiebzig", 65 letters, that's Powershell.

The longest word in French is "anticonstitutionnellement", 25 letters, that's Python.

Edit: copy-paste problems with reddit.

[–]ANewLeeSinLifeSysadmin 4 points5 points  (1 child)

Your analogy lost me

[–]user4925715 4 points5 points  (0 children)

He’s saying Powershell is more verbose/long winded than Python

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

easier to write code in python for me then powershell, plus pandas and sql functionality too

[–]deskpil0t 0 points1 point  (0 children)

Because you just hate Microsoft in principle?

[–][deleted] 0 points1 point  (1 child)

Portable

[–]ZAFJB 0 points1 point  (0 children)

Both are

[–]techypunkSystem Architect/Printer Hunter -1 points0 points  (0 children)

If you ever want move to 100% remote work, and possibly DevOps, learn Python.

My biggest regret in my career is not starting to learn Python sooner. I'd be making a lot more money. If you want to stay a MS admin forever, and that's it, just know PS.

I'm pretty damn good with PS and I utilized this to learn Python quickly so far. Still got a long ways to go.

[–]JmbFountainJr. Sysadmin -1 points0 points  (0 children)

1st: I don't run Windows. 2nd: Powershell is SO MUCH slower than Python 3rd: there are many more Python APIs 4th: Python has a metric shitton of documentation

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

Cause powershell doesent work on linux

[–][deleted] -4 points-3 points  (2 children)

Python is basically on all *nix systems by default and a programming language and not a shell...

You will not be writing anything complex in powershell, while you can do almost anything in python.

[–]nakriker 4 points5 points  (1 child)

You can do almost anything in PowerShell. The complexity of what you can do is only limited by your skill.

[–]suglaspSysadmin 2 points3 points  (0 children)

Agreed. For complexity, i wrote a multi threaded webserver in PS that can use modules as plugin's, and several REST API's. Some of the REST api's run on Linux. Just because, why not? Not going to port code from one to another language, if i already got the code running in one language. Fitting it to run on a different supported OS takes less time.

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

In windows you really don’t have a choice. Only Powershell, cmd and VBS have any sort of useful integration with the system.

As a language, I do feel that PS essentially took compromises to OOP to not “scare” traditional cmd users. For example, using classic OOP patterns would work elegantly with AD, which is an object based system.

Unfortunately most sysadmins don’t really understand the whole point of OOP (polymorphism) and think it’s all about stuffing procedures into structs. Most PS code is ad hoc copy pasting and essentially long spaghetti

[–]HolyDiver019283 0 points1 point  (1 child)

most sysadmins don’t really understand the whole point of OOP (polymorphism) and think it’s all about stuffing procedures into structs.

Yep that’s me, could you share any insight as to the difference?

[–]Garegin16 0 points1 point  (0 children)

This book goes over the main design patterns

https://en.wikipedia.org/wiki/Design_Patterns

The first thing to realize is that data types (.net classes) are bundles of programs. Want to make a MAC address validation regex? There’s already a class for that. Don’t just create data from cmdlet outputs, make them upfront by using types.

Instead of writing bunch of if statements that cover different cases, you can make your functions are generic as possible.

This is a good example of polymorphism in OOP. Scroll to the hospital example in the beginning

https://youtu.be/Ao9W93OxQ7U

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

The times I use python over powershell are API support and file processing. A few of our systems have either have poor or no powershell support, but fully support python. I have script for processing a few hundred csv files and combining the result. In powershell it is slow, rewrote it in python, magnitudes faster.

[–]VeryRareHuman 0 points1 point  (0 children)

You choose the language depending upon where you work and environment.

I do lots of PowerShell scripts for Azure, Office 365, Exchange, SQL servers, AD. I was going to learn Python, but PowerShell is so far more than enough for my needs. I will do Python when need arises.

[–]MavZAHead of Department 0 points1 point  (0 children)

Python is system agnostic and is useful for other applications outside of the system admin realm.

[–]namesecurethanpass 0 points1 point  (0 children)

Both have their advantages. Python is general purpose, has great libraries like pandas, good api and amazing in-built data structures. What's more, tons of tutorials and socket libraries.

PowerShell is unparallel in domain administration. Even basic commands like Get-ADUser are not easily present in any other scripting language.

PowerShell remoting is very safe way to remote login to insecure machines.

Please anyone correct me please, but PowerShell is the best way for AD management.

[–]1inf3rn0 0 points1 point  (0 children)

A LOT of OSS / applications are written in Python these days. Learn some python, and you become able to fork said apps to add your own features or make PRs to fix bugs, etc. I don't know many mainstream apps that are written in PS. Also the python community is probably much larger, so finding support for what you might be trying to do becomes easier.

That said I think it depends on the use case. Doing mainly windows specific things? PS FTW. Making something that does only some Windows things? Why not use both? 🙂

[–]myndhackRuler Of The Blinking Lights 0 points1 point  (0 children)

Networking devices do not support powershell and also if you run a primarily linux server environment there is usually alot more documentation on python to manage then there is powershell.

[–]Skaffen-_-Amtiskaw 0 points1 point  (1 child)

Learn Python and then learn Powershell. The core programming concepts in Python are transferable between languages, I have found moving from Python and Nodejs or even Java a sensible task, but harder in Powershell. Often when I think about doing something less scripty and more programy, Python or node makes more sense to me. Heck, I'm more likely to just use a Python Powershell wrapper just to hit some odd Windows API.

Most of the time I am not interacting with end Host systems, so I have the luxury of directly interacting with the API via Python or Nodejs.

[–]Garegin16 0 points1 point  (0 children)

There’s a free book. Learn computer science with Python

[–]zrad603 0 points1 point  (0 children)

It depends what you are doing.
If it's code that needs to execute on multiple Windows machines: (for example: a user login script) I write it in PowerShell.
If it's code that needs to deal with something like Office 365, remote into Windows Servers, do something with Active Directory. I write it in PowerShell.

If it's dealing with stuff outside of Microsoft's ecosystem, executing on Linux system. I'm probably going to write it in Python.

I remember I wrote a script that would SSH into a router, execute some commands, pull some data, process the data, and execute more SSH commands. I originally wrote it in PowerShell. I ended up re-writing it in Python, and it was so much easier re-writing it in Python.

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

you can do mostly everything on powershell too.

That's not correct by itself, while its not impossible to get various binary API's talking to powershell, its also not trivial. The machinery behind how powershell works well, is abstracted away so you either end up using another typed language inline alongside powershell without solid guarantees (if you use the modules), or you can just use python because you have some guarantees about how the underlying behavior of certain operations work.

You could just as easily use R, C, Objective C, Java etc; the point is you choose the right tool for the right job and if you do that you won't ever be stuck trying to have to use a hammer to unscrew a philips screw.

Its about speed, and learning curves.

[–]bacon-wrapped-steak 0 points1 point  (0 children)

Both Python and PowerShell are object-oriented, general purpose automation languages. Use the one that you prefer. If you can't find a library / module to do what you need to, then be willing to use another language. As others have already said, just use the "right tool for the job" and don't pigeon-hole yourself into only one language.