r/PowerShell • u/Lotus_Domino_Guy • Aug 26 '26
News OMG, I love powershell
I've been coding for 2 decades, and I recently had a payroll system to Active Directory project to do, and went with powershell. It's done, it works great, and I was looking at the code today, and spontaneously declared "I love powershell". its a remote day, so no one looked at my funny, but I'll list 3 reasons I love it. Feel free to add more.
No confusion with =, == or ===.
- Simple equals logic, no bizarre conventions: Do you know how many times I've had to fix code in JS where someone did if (variableName=something), which of course sets variableName to something, not compares it. Powershell's -eq and -ne is so much better then =, ==, ===, !=, or <>.
2)No line termination character: Line's don't require ; to end. Ok, that isn't a big deal, and my IDE would catch it anyway, but its just a waste of characters to terminate every line of code.
3)String composition: In other languages, mixing variables and text is something like "words " + variableName + ":/ more words" + variableName2. And then its like "Oh, is this one a + or an &...." With powershell I can just do varString = "words: $variableName :/ more words $variableName2" and it all works!
Now, its not like I make stupid syntax mistakes a ton in other languages, but in today's backend world, I'm expected to regularly code in 5-10 languages, and Powershell was amazingly easy to learn and the syntax is just clean.
I thought you Powershell vets might appreciate a newb's perspective on it, especially since its all positive.
50
u/Creddahornis Aug 26 '26
I'm going to pretend I've never ever done this myself in PowerShell ...
41
u/ankokudaishogun Aug 26 '26
Not that simple. Especially when
$nullis involved, some comparison shenanigans exist.see https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-null
But it's mostly simple.
45
u/Expensive_Finger_973 Aug 26 '26
I find that a lot of people in IT type ( and programming as well I would imagine) roles don't appreciate how great Powershell actually is unless they have spent some time having to write moderately complex things as old school batch scripts, shell scripts, or something like JS.
Having said that, Powershell can also be horrific in its own unique and interesting ways.
6
u/sysiphean Aug 26 '26
Welcome to the cult! Ask Billy about a membership card. The bloodletting ritual is Tuesday at noon, followed by coffee and a light lunch.
But seriously, yea. It isn’t a perfect language, but there’s no perfect one, and this is a really useful one. Simple enough for beginners to use, complex enough to do a ton of useful things. I love the operators syntax (though it is adopted some of the faster-but-harder-to-read things like ternary operator syntax), how the commands all (theoretically) tell you what they will do to what things via Verb-Noun naming, and the flexibility of its work with strings. Plus you can run (almost) everything line by line on the command line to check as you go. Oh, and Get-Help to help with everything in console, in a window (-ShowWindow), or in the browser (-Online), including the mountain of about_* topics.
5
u/Allcaponero Aug 26 '26
I share the sentiment on PowerShell but most modern languages share points 2 and 3. Semicolons are just not a thing with most modern languages (bit ironic that C# still has them :D). Even more so the case with string interpolation where even Java had it added.
5
u/dova03 Aug 26 '26
Learning that PowerShell was object oriented helped me to become a lot better at system architecture and scale.
3
u/Mr_ToDo Aug 26 '26
My joy comes from just how easy it is to pipe things and not worry about needing to parse the output first most of the time
So many of my batch file scripts became one line powershell commands
2
u/ipreferanothername Aug 26 '26
i also love powershell and kinda learned both javascript and powershell the hard way about the same time - its got its quirks and things i can complain about, but a lot of my excitement also comes from it being object based. we have some azure work starting here finally and the engineers hired are writing in bash and ugh, the object oriented bit of powershell just makes even basic scripting so much easier to do and read for me.
2
u/Flettys Aug 26 '26
I mess up assigning variables vs comparing them in every language.
Output stream redirection isn't so important that it needs a special character.
2
u/uptimefordays Aug 26 '26
PowerShell is also great for working with APIs! I also love cross platform pwsh because it doesn't get in the way of say python installs or require a virtual environment or any of the other python related headaches I enjoy.
2
u/rw_mega Aug 26 '26
Powershell is great, and you can rewrite legacy code in ps1 to modernize it. Make it easier for you to understand, manage, organize.
Problem with powershell is the security hole it creates. Allowing users to run scripts becomes a huge problem. Coming from a sysadmin or cyber security standpoint you want to set-executionpolicy restricted and not allow users to even run scripts. That’s how problems start. Or at the very least only allow authorized people to run said scripts
Learn how to let your environment trust your scripts with this enabled and then you will be better spot.
Signed scripted, trusted source, list goes on.
2
u/YouLostMeAtWorm Aug 26 '26
I loved PowerShell for two years. Now I love C# instead, but PowerShell is still an occasional mistress
2
u/jimross2 Aug 27 '26
I'm a fan being able to inline C# when you simple need more performance or to tap into deep some internals. Oh and it's bundled in Windows, along with a .NET compiler. Deployment made easy!
2
u/mrmattipants Aug 29 '26 edited Aug 29 '26
I know the feeling, as I felt this way, myself, when I started using it, back in 2019, to perform Active Directory related tasks, in bulk. And several years later, I'm still learning new techniques.
3
u/BlackV Aug 26 '26 edited Aug 27 '26
heh
&- Background operator (xxx &) or Call operator (& xxx) depending where you put it on your line&&- Pipeline chain operators , we're just gonna use&again cause we can?||- Pipeline chain operators, is that a pipeline or is it not?,- Comma operator for arrays,,1this is an array ??- as a ternary operator, oh there is a?in the middle om my code is it awhere-objector a fancyifstatement? what happens if I nest these things???- Null-coalescing operator, is it null or is it not ? (and I guess??=and its ilk)Clear as mud ;)
2
u/power10010 Aug 26 '26
Ever seen bash?
1
u/No_Split11911 Aug 26 '26
As a configuration manager admin I was never allowed to hate on PowerShell. It is my products language. I’m glad you’re enjoying it. Godspeed on your journey and I hope to see you post some neat things you’ve created in PowerShell in the future!
1
u/Fallingdamage Aug 26 '26
Welcome to the club. 79 and sunny every day :)
1
u/420GB Aug 26 '26
Try
1,2,3,4,5 -eq 2aka$LIST -eq $SINGLE_VALUE1
u/Antique_Grapefruit_5 Aug 26 '26
It is really great for data manipulation!
1
u/jeffrey_f Aug 26 '26
Powershell is meant for windows stuff and it is great.
I enjoy taking a repeating process that takes multiple minutes per step and squeezing it down to multiple minutes to create the script and seconds to run.
1
u/ILovePowershell Aug 27 '26
Absolutely, they made powershell incredibly easy to use.
1
u/sisrace Aug 27 '26
Then Microsoft depreciated half of the cmdlets
1
u/FalconDriver85 Aug 28 '26
As I have been a .Net developer in my previous (professional) life, I agree PowerShell is indeed one of the best options today.
But why something that is trivial in e.g. Bash like knowing if a command ended successfully ($? equal to 0) requires a lot more effort and is cumbersome AF in PowerShell?
1
u/hsm_dev Aug 31 '26
For me it is the simple fact that the standard library is great and most things natively works with objects. This makes the mental model easy. If everything is an object I know the functions I can call, how to pipe it etc.
When ever I write bash, the mental overhead of piping strings through a whole set of tools that has their own quirks is what usually ends up breaking things for me.
And hey, since PowerShell is just a shell, from my Mac/Linux box where I run it, I can simply just call any of those binaries if I need them for a specific job.
All this combined makes it fairly trivial to write very clean feeling functions where I can pass objects between them through pipelines while keeping my intended interactions through the functionality of advanced functions and cmdlet bindings.
1
u/chickenfriedric3 Sep 01 '26
In JavaScript, there’s template literals in ES6.
You can append in one line as
const fooBar = `Big long ${var}`
Modern compilers can append ; to the end of your code so you don’t need to
1
u/Glum-Highlight2734 Sep 02 '26
This is honestly how PowerShell gets you 😂 You start using it for one project, then suddenly you’re wondering why other languages make simple things feel so complicated.
1
u/Vx7Qn4Lz Sep 22 '26
Do you employ preschoolers?
1
u/R-EDDIT Aug 26 '26
I love powershell. But I've seen people have bugs due to misusing quotes/double quotes, getting variable names literally or literal values interpreted.
1
u/wesleyoldaker Aug 26 '26
I also like PowerShell sometimes, but I also hate it sometimes. I think the more I've gotten used to it the less I end up misusing it so part of that was on my end, getting as familiar with it as I was with bash at one time.
However, there are still a few things that I still don't particularly like about it.
But there are a lot of really nice features of powershell that i have come to like too. It probably looks like I am just crapping on it but really there are a lot of ps1 features that I prefer over bash's style. Unfortunately I gtg now but hopefully I'll be able to come back later and sing its praises with y'all in a part 2.
0
u/AssistanceDizzy9236 Aug 26 '26
If you need to use a module is game over. It really sucks.
0
u/MonkeyNin Aug 26 '26
A bunch of languages have format strings
If you are using javascript, the backtick operator is really nice for string interpolation You get interpolation and don't need to escape quotes. ( Powershell requires a here-string:
@" ... @"prints
Python is similar
For dealing with relative paths, the standard lib
pathlibis powershell's Join-Path but with a lot of features: python.org/pathlib-13
u/VirtualDenzel Aug 26 '26
1 is one of the most hated forms of ps.
Paupershell (as we call it) is terrible since it goes against all other coding /scriptting languages in just ignoring standards and pushing their own shit. =,==,=== is so much more universal then doing -eq or -ne etc. Its just terrible.
Maybe if you are a junior and all you can do is code in paupershell its fine.... but if you work with more languages then its frustrating as ****
2) never had issues with line terminating. Sure php uses ; , but thats not a big deal at all. Way more comfy to remember then all those exceptions paupershell forces us to do.
3) you are wrong there. Powershell can bork very easy with string / variable concactination. And you do not need to do $var + ' string ' + $var. You can easy insert them into strings using "" and $($var) text bla bla"
Powershell is inefficient. Its badly designed. Terrible out of date documentation. (Especially when it comes to graph). Saying powershell is lovable is like saying windows 11 is a good OS. It just does not compute.