r/PowerShell • u/Cloud_Strifeeee • Aug 18 '19
What you prefer in Powershell compared to Bash/Python ?
1) What you prefer in Powershell compared to Bash/Python ?
2) How long does it take for someone who already did some programming (C++/C#) and know a very little of PS to become a PS guru and create/automate big scripts etc ? like 6months 10 hours a day or more ?
3) I am studying my Windows Server and Linux and I talked with a lot of (Linux only) admin.. and a lot of them prefer Bash/Python and say it is more powerful or better.. Why there is so much a Bias toward their tech compared to PS ? they are jealous that PS is more modern or more powerful ?
6
u/NotNotWrongUsually Aug 18 '19 edited Aug 18 '19
Consistency. While the whole Verb-Noun structure seems a little contrived at first it is actually very helpful in the long run.
Discoverability from the shell. Documentation is built-in, consistent, and usually with clear examples.
The ability to build powerful, parameterized applications that behave natively, with just a little more effort than building a normal script.
Specifically compared to Bash: objects on the pipeline, rather than text. It took a while to re-align my thinking, but damn, I don't miss having to sed, awk, grep, and cut my way through everything.
A Shell with auto-completion built-in (the people who criticize the language for verbosity must have broken TAB keys).
2)
Too individual to really answer. With prior programming experience, and doing 10 hours per day for half a year you certainly should be a guru.
Much shorter would likely do as well.
3) People will prefer what they know. You can use bash from Powershell Core, along with your Powershell, so considering bash more powerful in itself seems silly. You don't really have to pick.
Python certainly is more powerful, in terms of what you can do, if you consider the absolutely stupid number of modules that you can get your hands on. I find it takes longer to use for the same admining tasks though. I mean, in the end, assembly language is even more powerful right? ;)
Edit: There is a lot of stuff I wouldn't be attempting in Powershell but would just use Python for to begin with.
6
Aug 18 '19
Please stop answering this fuckwits questions. He has been asking the same shit every single time for the past few months.
1
u/SirWobbyTheFirst Aug 18 '19
Oh god you’re right, I remember posting on one of his threads before knowing it was bait. His posts seem to get removed by the sysadmin sub all the time.
1
u/concussedYmir Aug 18 '19
Bait for what though? What emotional rabbit hole is there to find in a discussion between Bash and Powershell?
1
u/SirWobbyTheFirst Aug 18 '19
It was something to do with whether PowerShell on Linux was more powerful than Bash on Windows or some fucked up question where the goal is to start a flame war.
I remember commenting on it saying something like "Nice try" and then downvoted and reported. 👍
-2
u/LoL4Life Aug 18 '19
Maybe he hasn't found the answer he's looking for.
3
Aug 18 '19
Maybe he hasn't found the answer he's looking for.
Maybe he should start putting some fucking effort into his posts instead of asking vague as fuck questions with 0 relation.
3
u/LoL4Life Aug 18 '19
I don't completely disagree with you, but you appear to be unnecessarily angry.
1
Aug 18 '19
I don't completely disagree with you, but you appear to be unnecessarily angry.
Because jack shit gets done about it.
1
4
u/kn0rki Aug 18 '19
i love ps and bash .. but i didnt understand why poeple love python ..
linux only admins? most of them (and open source community) are narrow-minded and didnt accept any other thing.
2
u/Slash_Root Aug 18 '19
linux only admins? most of them (and open source community) are narrow-minded and didnt accept any other thing.
Really? I agree I use it because it is popular and a lot of our tooling is built with it (Ansible). However, *nix administration has way more diverse tooling. Bash, Python, Ruby, Perl, and Go are all common.
2
u/wonkifier Aug 18 '19
I despise python.
The language itself isn't bad once you get used to it, but the amount of work I have to do to setup an environment or use modules is annoying.
1
u/Slash_Root Aug 18 '19
The situation around packaging/dependencies is a nightmare. There are several different tools and they are either broken up, not widely used, or have annoying bugs with PATH (looking at you
pipenv). It is in a better state now, but they need to standardize on something with a single binary. I know that discussion has been going on for a while in PEPs.
2
u/ka-splam Aug 18 '19
Why there is so much a Bias toward their tech compared to PS ? they are jealous that PS is more modern or more powerful ?
Nope, they don’t believe it is. They hate it for saying “Microsoft” on the tin, because Microsoft iswas an abusive anti-competitive standards-breaking monopolist with no taste which makes bad tools like IE6 and Windows 98 and Outlook, and locks people into them.
a lot of them prefer Bash/Python and say it is more powerful
Take two bottles into the shower? I guess it’s even more powerful if you add the GNU utilities? sed? Awk? Perl? third party python modules? Amazing.
3
u/blockplanner Aug 18 '19
Powershell has a better API for most things you want to do with the operating system. Almost everything is accessible and almost everything is consistent. (the exceptions generally involve calling functions from .net libraries)
If you have a good understanding of program flow you can probably get some big scripts and automation done just by reading the documentation as you go. However, scripting is different than programming in the same way that writing a function is different than writing a program. A few months of regular use and reading up on the basics is enough.
You will have a hard time finding a linux only admin who appreciates any Microsoft technology. If they thought it was better they'd be using it.
12
u/DennisLarryMead Aug 18 '19
Sysadmins, as a rule, have a hard time breathing if they're not complaining about something. Kind of like how sharks will die if they stop swimming.
3
u/technokhan18 Aug 18 '19
Going to chime in on #3 speaking as a Linux only admin at my place of work. I whole heartedly embrace Microsoft technology. PowerShell being one of the big ones. For me each language has its purpose. For our use PS does a lot of the heavy lifting as Windows runs the core infrastructure like AD, DNS, DHCP and the like. However we have a huge Linux foot print as well. Where PowerShell falls short integrating with those systems Python/Bash fill in the gaps very well. We use a mix of PS and python to drive most of our automation.
So as you said. The Pro-Windows Linux admins do exist, we just indeed may be rare. Lol
Just my two cents!
2
u/jantari Aug 18 '19
I like curly brackets, do-until loops, the
1..10range operator (just syntax in general) and the fact that everything is built in. With Python you often need libraries, some of which are third-party so have to keep track of their updatesIt took me a year just using it at work, so maybe 4hrs/5days/week + 2 home projects on the side
Bash and Python are more powerful and better - for Linux, so their assessment is completely fair when you consider their use case
2
u/SirWobbyTheFirst Aug 18 '19
Fun fact, I find if you don't go into subreddits and actively ask questions designed to bait people and then never respond when people answer or call you out, it can go a long way towards people not being biased.
Namely, asking a sub for Linux Admins about how good they are at setting up Server 2016 and Server 2019. What exactly were you hoping to achieve there?
2
u/MurderShovel Aug 18 '19
I think Bash is preferred because you have access to pretty much any Linux command or application you have on your system as well as all the stuff built into Bash. You can run your whole Linux system from the command line and script it via Bash. Windows can do a whole lot from command prompt, more than most realize, but not everything.
4
u/sid351 Aug 18 '19
Really? I'd question that.
With Powershell I don't think there is anything you can do in the Windows GUI that you can't do in Powershell (which is different to the cmd command prompt, but is effectively its replacement).
Now with 3rd party stuff you may be right.
1
u/OnesimusUnbound Nov 30 '25
Everything is an object makes sense to me personally as I have background in object orient programming.
The objects are essentially .NET objects. so C# folks have an edge. The main challenge is the unfamiliar syntax which is inspired from shell scripting, and in turn different from any C-based syntax.
It's more of bias with what you know (see my reply in question 1). Right now I'm developing in a Linux distro with a side project and bash is very hard for me to grasp, but Python is easier once you get around the required indentation and that python has some OOP element.
1
Aug 18 '19
Personally, I feel many people dislike Powershell because of there a a lot of gotchas that can create confusing errors and unpredictable behavior. Prior coding experience will help but could also be a source of frustration.
That being said, if you write defensively and leverage .NET it can be very powerful and quick to write in. For automating tasks in Windows it is my preferred language.
Also Powershell ISE is a pretty good environment to write/debug in though, again, some weird gotchas.
0
u/DennisLarryMead Aug 18 '19
The enforced white space/ formatting of python just makes far more sense to me. Also I'm not a big fan of the powershell syntax.
But the reality is when you get paid to do a job you gotta use the tools that make the most sense.
7
u/ps_for_fun_and_lazy Aug 18 '19
The white space formatting of python and yaml is one of my biggest pet peeves, I like braces they are great but maybe that's all the languages I have dabbled in showing through.
4
u/Colorado_odaroloC Aug 18 '19 edited Aug 18 '19
Thank you. As someone who has to use several different command lines/scripting languages, I despise Pythons white space rules. If you use it full time, I'm sure it isn't a big deal, but it can be infuriating at times, and just seems like such an unnecessary pain in the arse.
7
u/blownart Aug 18 '19
I love powershell's freedom with variable conversion. That it doesn't care that I want to add an integer to a string and just does it. Also the white space is one of the things I hate the most about python.
1
1
u/harshal_20 Aug 18 '19
PowerShell is pretty easy to get started with cmdlets and scripts but to develop your own modules you will need help of c# or .net to use objects from it. PowerShell extending cross platform support day by day and making it easier to manage Linux, Windows and cloud.
Those who are used to with bash they continue to use it and also adopt ansible which has great plugins and modules available for Windows, Linux and Cloud management. Also, scripts or runbooks are written in yaml language which is easier and human readable more than PowerShell.
0
u/Lee_Dailey [grin] Aug 18 '19
howdy Cloud_Strifeeee.
[1] PoSh pref over python or bash
over bash - objects instead of text layouts that change with every freaking command. [grin]
over python - core commands have names that are more readable.
over both - a help system that works well for me.
[2] how long to get reasonably good?
likely 3 to 6 months of use-PoSh-every-day combined with some original scripting.
[3] preferences
those are preferences ... [grin]
folks stick with what they know until there is a clear benefit to change. right now, there is very little real benefit to an admin to switch from python to PoSh. switching for bash, tho, has already reached the point that it is well worth looking into - but not likely time to seriously consider PoSh a replacement.
take care,
lee
-1
Aug 18 '19
Powershell emulates what bash has done well for years already.
You can fix issues in Linux with a line of text, rather than a line of code in a software update.
0
Aug 18 '19
[deleted]
5
u/SirWobbyTheFirst Aug 18 '19 edited Aug 18 '19
Well it’s no wonder Windows Updates have been breaking shit left, right and centre or the fact that it’s going to take until 2020 before the Settings app can change the speed of the mouse cursor, we have someone who uses white space instead of braces.
Where a tab instead of four spaces gets you a runtime error that detonates your CPU.
0
Aug 18 '19
[deleted]
0
u/SirWobbyTheFirst Aug 18 '19
Know how I know you don't work for Microsoft? Because every company has a policy against responding to people like me on the Internet.
Why do you think Jen never responds to anyone not dishing out praise on the Windows subreddits?
If you are going to lie, at least try and be a little legit about it.
2
u/dogfish182 Aug 18 '19
This post needs more upvotes.
Most of my working life was as an MS sysadmin for enterprise orgs. I transitioned away and into the linux/cloud world about 3 years back.
People asking which is better, a windows scripting language or a full fledged programming language like python are just showing their lack of experience imo.
We use powershell when necessary, that’s usually in our infra deployment pipelines and we use python to deliver a ‘cleanup this ad object’ style payload of the necessary powershell script.
Attempting to drive all of our tooling and pipelines with powershell would be an exercise in futility unless you live in a pure azure world with MS only tooling.
The other way around is easy, python SDK for all clouds and you can do anything with it, winrm packages where needed to deliver powershell payloads to do active directory stuff.
I quite like it as a shell though, it being object oriented is a great choice.
13
u/system_badmin Aug 18 '19
pros:
Working with semi-structured data (JSON, XML, PSObjects etc) is an easy and built in consideration. I firmly believe some unix systems will follow down this path eventually.
Very cool that domain level commands available from single prompt (also dangerous)
.Net modules all you like, dbatools
I find it makes working with auth protocols personally very easy
Syntax looks nice, verbose in a kinda good way
cons:
Only as good as the Microsoft/Windows ecosystem (many caveats). If you can't do something from Windows you probably can't do it in Powershell (Fucking pin to taskbar!)
Python is more a scripting language than a shell, so good depending on what you're using it for. I'd use Python to build a website using Django or similar, wouldn't dream of doing it using PoSh. When people say that Bash is more powerful it's because of the con I mentioned above - you're pretty explicitly limited by the Windows/Windows Server environment capabilities (though this is changing with core).