I just don't find PowerShell fills a niche I need to fill, even though it seems to be really powerful and designed by smart people. I guess if I worked on Windows it would fill a niche since it has hooks into the system that are harder to reach in other non-MS languages.
It's not good for programming or scripting. There are so many good ideas in PowerShell but it's wrapped in a weird body.
At least, it doesn't insult you like Ansible tooling with the ^ YOU MADE A MISTAKE HERE BUT WE CAN'T BE CLEAR WHAT IT IS
It's such a shame powershell didn't come 2 years later, I feel like they'd have had no choice but to use C# instead of inventing a new language.
When you look at how admins get their job done, it starts in the interactive shell and then when the do things frequently, they put it into a simple script and when then need it to be more formal, they invest in making it production quality.
That is the flow that PowerShell was designed to support.
Jeffrey Snover [MSFT]
It's worth noting that all code in .NET is enclosed within a type (at a fundamental level .NET code is either contained within a value type or reference type, but knowing those names isn't important when you're starting out), so this doesn't limit you to creating/importing data types, you can use it to write inline C# functions too.
It's also interesting to note that the .NET Framework comes with its own .NET compiler, so you don't need to install any dev tools on Windows to code in C#, it's possible to do so with the tools that are available out of the box.
If you want to try out referencing C# code using Add-Type, the following article is a good introduction:
https://blogs.technet.microsoft.com/stefan_gossner/2010/05/0...
I can't pinpoint what I like so much about it either... It just draws me in well. It does devolve in readability when trying to squeeze out every drop of speed, though.
IPC is what I find to be the most challenging for me in PoSH, but I'm not sure if that's due to incompetence.
Jeffrey Snover [MSFT]
If these are flavors of ice cream, they're all pretty similar and taste good. Where is Powershell in this? It's certainly not vanilla or chocolate... it's more like pepperoni. It's like C# and Perl had a really ugly baby. Even simple things like using -eq and -ne for comparisons seems 40 years out of date.
That whatever space powershell fills on windows its not a niche .. not a niche at all
I agree with you, powershell is powerful and I guess benefit from being new .. it has amazing uniformity and amazing discover-ability
Anyway, I was saying, powershell fills automation on windows, it is THE automation tool on windows and has been for a while, there is hundreds of commands that you can you to manage and deploy and update almost anything important on windows
This is not a niche, not a niche at all .. it is as far from niche as i can think of
And now that it is being ported to other systems, it had the potential to be THE automation tool for many organization that have mixed environments
So you see, when it was primarily windows, it was not a nice, again because automation on windows is not a niche .. now imagine it beyond even windows
Powershell is about automation, not scripting, and not just the command line ... it is really about automation
Instead of following steps, you automated with one script ..or possibly a small GUI app
I was simply saying that PowerShell doesn't serve a unique purpose in my environment that isn't better served by other languages or shells. "Niche" was short-hand for, "This language is particularly well-suited for this task or set of tasks", and I wasn't (intentionally) saying anything about its popularity.
All programming languages have a niche where they are strong. It is not a way of saying, "This language is obscure or not used a lot." It's a way of saying, "For the things I do, I can rule it out, because I don't need to do the things this language does better than others." From what I can tell, scripting (or, "automating", if you prefer that term) Windows is PowerShell's niche. I don't need to script Windows, so I don't need PowerShell.
In short: Saying PowerShell doesn't fill a niche I need to fill is not an insult to PowerShell or a statement about how popular it is. It's merely saying I don't find it suits my needs in my environment (which contains no Windows servers).
That's where powershell failed abysmally.
PowerShell is useful on Windows because it does something that could not be done easily or at all before, that being automation without using GUI's. It does this by providing hooks into the Windows infrastructure to change settings and perform tasks without fragile registry edits and GUI manipulation. But UNIX systems have no need for this by virtue of it's command-line first design. If MS was still using DOS and ini files the situation would be similar.
So what does PowerShell really offer in UNIX land? Configuring and automating nix systems is drastically different than doing the same on Windows systems, so having a common scripting language probably does not help much.
I guess a better question would be what does PowerShell offer in the way of "automation" that is so much superior to bash and *nix command line programs.
1- it runs on both unix and windows .. and hopefully more in the future
2- uniformity, all command have the same form, verb-noun
3- discover-ability, you dont need google to find the cmdlet, you can glob search the help system
4- support, there are cmdlets for many systems that bash will never, ever, ever, ever approach or support
5- GUI, you can create a GUI in powershell
More than that, it has the entire CLR at its disposal, including the C FFI.
Jeffrey Snover [MSFT]
They've fixed this in recent versions by shipping actual curl binaries, but it's a useful illustration of how just aliasing popular shell commands to their Powershell alternatives isn't necessarily helpful.
& notepad.exe
Which isn't complicated I agree but annoyed me.
Just typing "notepad" is enough to launch it. The problems with powershell and executables only really come in to play when argument passing, where some escaping is necessary.
If you want to execute the EXE stored in a variable or whatnot, then yes, you need `&`, which I think is borrowed from Perl. But otherwise, the rules in PowerShell are the same as a Unix shell: if it's in the PATH, just type the command name (with or without the .exe); otherwise, use the full path.
The SO answer isn't wrong. The EXE there has a space in the path. The answer uses a string literal for it and thus needs &. It could of course escape the spaces with ` instead; then it wouldn't need a string literal and thus not need &.
I've done almost nothing with PowerShell due to the brutal syntax, would love to use a nice language like C# or Python for the control structure (logic, looping, etc) and then just calling out to PowerShell when needing to execute a function. Seems like that should be a possibility, although passing data through may be problematic.
Personally, for quick interactive stuff, I just `ls` when I'm sitting on a non-Windows machine. My finger muscle memory just does `ls -al` and `rm -rfv` when I'm sitting on a Linux box.
But if I need to do some heavy sorting/filtering, I'd much rather save the minutes wrestling grep/awk/sed/xargs than save the minutes on execution (or the hours on having just done some operation based on some grep/awk/sed/xargs work that I didn't properly test).
A few examples of the absurd things I found along the way:
It is impossible to update windows remotely with powershell. The only API to windows update is apparently a COM interface that refuses to be called remotely. I found a hack on a forum where I have to create a scheduled task that runs as a local admin user and trigger that task remotely. This is farcical.
The equivalent of ssh is something called powershell remoting. Of course opening that interface is a significant security risk that need to be monitored. However windows events records all failed authentication attempts on powershell remoting as a local connection and therefore does not expose the IP of the attacker. So much for monitoring.
Very few basic functions have been implemented in powershell, half of my powershell script is actually made of traditional batch commands, with all sort of random behaviors (like nslookup makes the script fail), inconsistent API, etc. It feels like using Windows 10 where we are stuck with half of our settings in an old control panel and the other half in a new one, feels sort of half baked. In addition some powershell commands managed to be inferior to their batch equivalent. Setting a registry key is a prime example (and god knows it is a common task), it takes several commands in powershell for something that is done in one command with reg.exe.
Of course there is no way to run a ps1 with admin privileges directly from the windows shell [1]
etc.
[1] winaero has a hack to do that: https://winaero.com/blog/run-as-administrator-context-menu-f... But come on Microsoft, don't you use your own product?
>nslookup
[System.Net.Dns]::GetHostAddresses('google.com') | % ToString
>In addition some powershell commands managed to be inferior to their batch equivalent. Setting a registry key is a prime example. ... it takes several commands in powershell for something that is done in one command with reg.exe. sp 'HKLM:\path\to\key' name 'value'On the registry, your command will fail if HKLM:\path\to\key doesn't exist whereas reg.exe would create the key automatically
It does not "crash" a powershell script for any meaningful definition of "crash".
I know a lot of people love Powershell though.
However some things will always be slower, aince powershell does more for you than bash does. Compare productivity from not scraping to consider the tradeoffs.
But in practice, I find it both cumbersome and very, very slow.
For example:
That's around a factor 80. Hmm. OK, startup costs, JITs hard time, yadda yadda.But it's not just that. For example I found a simple
to be more around 50x slower than the equivalent And so on.