5 ms·
I find PowerShell, the language, verbose and not very ergonomic. This ship has sailed, but I wish Microsoft had done something to make Windows automation a litt
by chem83 2y ago
I find PowerShell, the language, verbose and not very ergonomic. This ship has sailed, but I wish Microsoft had done something to make Windows automation a little closer to other platforms, so that it could benefit from the good software that exists on other platforms.
It seems that VBA will continue to exist as the programming front end for MS Office, which is unfortunate. They had announced Python support for Excel a while back and I wish it was better promoted as a viable VBA replacement.
- sancarn 2y ago> good software that exists on other platforms You mean like AppleScript?
- bossyTeacher 2y agoPowerShell is terrible. The idea is good, the implementation bad
- Someone1234 2y agoCare to go into any detail at all..?
- orthoxerox 2y agoIt has a very idiosyncratic syntax. The internals are great, but it's so unlike either sh or C that I, for example, just can't be bothered to remember it.
- bossyTeacher 2y agoIn most normal languages, a non-void function returns either null or some data. Normally, the type of data is always the same. So your function returning a string will never return an int. Either it returns a string or an int. In PowerShell this is not guaranteed for all the functions in packages supported by Microsoft. A function returning a list of strings, can sometimes return a list of something that are not strings. This is the first big issue I have with PowerShell. The language is very quirky. Simple stuff like using variables is not as intuitive as it should be. Another issue is encapsulation of logic, it is not straightforward at all. This is my second big issue. Trying to temporarily disable script policies to run a script is not straightforward either.
- 7bit 2y agoSkill issue, git gud
- levidos 2y agoPowerShell is amazing
- ravenstine 2y agoI always wondered why Microsoft didn't just clone something like Bash as close as possible. Powershell was different enough from UNIX that I couldn't get myself interested in it during my phase when I was using both Windows and Linux.
- ygra 2y agoJeffrey Snover once answered this on Stack Overflow. The answer is that bash and all the other Unix tools wouldn't help you very much on an operating system where things are accessible via an API and not via text files and command-line programs. That's why PowerShell also has "drives" for things like the registry and the certificate store. Even functions, aliases, environment variables and PowerShell variables get their own drive, funnily enough.
- 7bit 2y agoBecause these people didn't want another relict that only does text manipulation. If you love awk and sed, you can use Bash. If you like to work with real objects, use PowerShell...
- lasermatts 2y agoA deep chill ran down my spine as I remember all of those VBA tools I updated/generated during my first internship... some of those are still being used in some semi-industrial applications.....
- kijin 2y agoNo worries, they probably haven't updated Excel since you left.
- BMc2020 2y agoIIRC, MS has not updated VBA since 2007, but they can't get rid of it because of the millions or billions of spreadsheets out there that still require it. They are trying to push excelscript aka typescript aka office scripts but uptake has been very slow.
- Turing_Machine 2y agoYep. Turn off VBA and the world burns. That's only a slight exaggeration, if it is an exaggeration at all (there are all kinds of splody things that are managed by VBA scripts that some intern wrote back in 1999, or that can only be modified by Bob, who retired back in 2006).
- NoahKAndrews 2y agoYeah, I like the ideas behind PS, but Nushell implements them so much better (it's yet to be stabilized though)
- Someone1234 2y ago"Nushell" has a "TODO" for half the basic features, like flow-control. Can you go into specifics about exactly what Nushell is implementing "so much better?" Powershell is a mature offering that uses standardized (albeit verbose) naming to allow you to infer what a command should be called Verb-Noun (Get/Set/Start/Stop/etc)-(Process/Service/File/etc). People are welcome to critique Powershell but more often than not they don't state what the problem actually is.
- NoahKAndrews 2y agoYeah, Nushell definitely is not production-ready, though it's still very useful in its current form. My main complaint about PS really is the verbosity.
- zamadatix 2y agoIt may have a separate timeline but it does seem to hint at going out the door in similar order on Office as well. I think the Python in Excel stuff is still in beta but things like lambdas, regex or Office Scripts all actually work (even on the web versions) and start taking big bites out of why you'd want to look at VB. New Outlook dropped VB support even on the desktop and I don't think they plan on maintaining separate development platforms for the other apps forever.
- Someone1234 2y agoPython in Excel could have been amazing, except Microsoft executes it in a cloud environment and require a Cloud Service account to even open spreadsheets with it in. I'd strongly recommend people avoid Python in Excel, it is a Trojan Horse into forcing you to subscribe to access your own spreadsheets.
- pavlov 2y agoIt’s ironic that Microsoft was founded to provide software for microcomputers where the whole idea was that you own the CPU and don’t need to pay anyone or ask permission for access. And now they’re full circle back to mandating the timeshare computing model even though the local CPU has incredible performance. Maybe they should rename to Centralsoft.
- dragonwriter 2y agoAFAIK, Python in Excel is fine, but only if you don't use Microsoft's: https://www.xlwings.org/ https://www.xlwings.org/
- pitaj 2y ago> It seems that VBA will continue to exist as the programming front end for MS Office They already recommend that new projects use their JS-based Office Scripts instead.
- sancarn 2y agoNot sure about other people but most of my apps I've made actually can't be made in Office Scripts... They are useless for my needs.
- avidphantasm 2y agoI don’t like the verbosity either, but have come to appreciate it as a cross-platform scripting tool for technical people who aren’t programmers. Again, it’s verbose, but more approachable for these new users than unix scripting languages. Being able to run scripts on macOS and Linux is a bonus. Given all this, I’ve come to peace with PowerShell.
- ravenstine 2y agoWith WSL2, is there any objective reason to write new Powershell scripts in 2024? I am genuinely curious because I barely have used Windows these days and had some brief experience with WSL2.
- orthoxerox 2y agoBash has no access to Windows internals. Some parts of Hyper-V you can configure only through pwsh, there's simply no GUI there to do it.
- sterlind 2y agoPowerShell lets you script Windows itself. You can configure network interfaces, set group policy settings, change registry keys, install programs, gather diagnostics, etc. etc. Linux has systemctl, Windows has Start-Service. Linux has kill, Windows has Stop-Process. Linux has ip, Windows has Set-NetworkInterface. WSL2 is just a VM - one with a ton of slick host integrations, but a VM nonetheless. Its power to do anything to Windows itself is very limited. It's also not installed by default. Disclaimer: work for MS, not on PowerShell or WSL.
- 7bit 2y agoIf you love awk and sed, no. If you rather work with objects, yes, absolutely.
- chem83 2y agoYes, there is. If you write bash to execute on WSL2, you’re just orchestrating the Linux VM (that runs on Hyper-V and is cleverly integrated into Windows and makes you feel like you have a native bash shell). If you want to automate Windows using bash, you need some runtime that translate all Linux-like calls to the Windows COM interface.
- jasomill 2y agoIn addition to the reasons already stated, WSL2 is a heavy dependency. Compared to PowerShell: 1. Typical WSL2 distros require far more disk space. 2. RAM used by WSL2 may not be immediately freed when your script exits. 3. WSL2 distros don't auto-update, so telling someone to install, e.g., Ubuntu via the Microsoft Store is insufficient to ensure a well-maintained WSL2 instance. 4. WSL2 requires enabling Windows hypervisor support, which can be difficult (KVM) or impossible (non-bare metal EC2 instances) in virtualized Windows instances. While (1) is probably not a big deal and (2) and (3) have reasonable workarounds, (4), where relevant, tends to be a showstopper.
- 13of40 2y agoIMO, the problem isn't that you can't use it in a terse way, it's that even though it gives you lots of options for terseness (type, cat, and gc are all aliases for get-content, for example) people naturally try to code in the canonical way and they assume that's the long-form cmdlet names. In Unix, "ls" is what you get so it has to be canonical. In PowerShell you can use ls or dir or get-childitem but there's nothing to hint which is correct to use in a proper script, so when you see example code it looks like "get-childitem | foreach-object {...}" instead of "dir | %{...}"
- ygra 2y agoScripts should not use the aliases because they can differ across machines or users. The cmdlet names are stable. That being said, for quick one-off scripts my code looks very much like my command-line usage, which is somewhere between terse and golfed. Idiomatic PowerShell embraces the pipeline, though. The number of scripts I've seen in the wood which were haphazardly ported from VBScript or C# showed, however, that people don't care about idiomatic.
- 13of40 2y agoBuilt-in aliases are guarateed to be present, so you can depend on them. There are other features, like shortened parameter names that might become ambiguous when new parameters are added, that aren't guaranteed backwards compatible, but aliases are stable.
- jasomill 2y agoNot necessarily: 1. UNIX-compatibility aliases like "ls -> Get-ChildItem" and "cat -> Get-Content" are not defined in PowerShell on Linux or macOS. For a complete list of these, see the PowerShell source code[1] (look for "#if !UNIX"). 2. A number of aliases from PowerShell ≤ 5.1 were removed in PowerShell Core (≥ 6.0), including the particularly annoying "curl -> Invoke-WebRequest" (conflicts with curl.exe) and "sc -> Set-Content" (conflicts with sc.exe). [1] https://github.com/PowerShell/PowerShell/blob/8ea1598964590b7551ffacda2d2007b94da1e5fa/src/System.Management.Automation/engine/InitialSessionState.cs#L4695 https://github.com/PowerShell/PowerShell/blob/8ea1598964590b...
- 7bit 2y ago> I wish Microsoft had done something to make Windows automation a little closer to other platforms, so that it could benefit from the good software that exists on other platforms. PowerShell is cross-platform and works und Ljnux and MacOS as well. And it's extremely good on itself already, because everything are objects, instead of just strings (bash, etc.). And because it's .NET you can seamlessly write anything you like including kernel calls, etc. without ever needing something like a 3rd party package like you would with e.g., Python.
- nozzlegear 2y agoIsn’t PowerShell itself the third party package? At least on Linux and MacOS, I mean.
- chem83 2y agoYeah, it is. S/he’s missing the point. Good luck finding PowerShell pre-installed on any server or workstation. Is there even a non-MS sponsored distribution that includes it by default?
- 7bit 2y agoYou're missing the point. Anything Microsoft would have done would have been a 3rd party package to Linux.
- jasomill 2y agoKali Linux: jtm@aristotle:kali ~ $ apt-rdepends -r powershell Reading package lists... Done Building dependency tree... Done Reading state information... Done powershell Reverse Depends: ibombshell (0~git20201107-0kali2) Reverse Depends: kali-linux-headless (2024.2.8) Reverse Depends: offsec-pen300 (2024.2.3) Reverse Depends: offsec-pwk (2024.2.3) ibombshell Reverse Depends: kali-linux-everything (2024.2.8) kali-linux-everything kali-linux-headless Reverse Depends: kali-linux-default (2024.2.8) Reverse Depends: kali-linux-everything (2024.2.8) kali-linux-default Reverse Depends: kali-linux-everything (2024.2.8) Reverse Depends: kali-linux-large (2024.2.8) kali-linux-large Reverse Depends: kali-linux-everything (2024.2.8) offsec-pen300 offsec-pwk
- sancarn 2y ago> They had announced Python support for Excel a while back and I wish it was better promoted as a viable VBA replacement But the existing implementation of Python means that it's not even close to a viable replacement lmao