4 ms·
While Powershell is pretty great and I use it all the time, I still think it falls short of Bash in terms of how integrated it is with the rest of the system. T
by astine 7y ago
While Powershell is pretty great and I use it all the time, I still think it falls short of Bash in terms of how integrated it is with the rest of the system. The shell is the default way to get things done in Linux but it feels more like a second-class citizen in Windows. This is a shame because there is clearly a lot of good engineering in PoSH.
- majkinetor 7y agoNah, integrations to the system are orders of magnitude better then bash. Powreshell is automation standard for basically all MS tools and tools of many other big companies. You can host powershell in your app with 5 lines of code (not something you can easily do with bash). Its designed to be integrated into everything. When my sysadmin GUI clicks vmWare I open PowerCLI. When my db admin uses networker for backup I use Sql Server Powershell Module. When my web dude clicks in IIS management studio and forgets the click I give him unmistakable ps1 script that crates IIS site and sets it up in 5 lines of code. Its like that forever. Poweshell is no typical shell - u do business stuff in it, not text parsing all the time like in bash with 0.1% of what you actually want to do. The thing that i personally miss is exporting config of Windows (control panel and friends) as powershell script(s). Something like DSC (or better, BoxStarter) but for grannies - press Start -> export everything to powershell script -> reinstall -> run ps1 -> run chocolatey -> show FTW sign.
- astine 7y ago"Its designed to be integrated into everything." But it isn't. Try managing AD servers using powershell. You have two options. Either the powershell AD module, which is incomplete and doesn't cover the entirety of Active Directory, or you resort to the native .Net API which is ugly and unintuitive when used from a command line. "When my db admin uses networker for backup I use Sql Server Powershell Module." Wut? Don't do this. I've used that module and it's fragile as hell. You have to check the arity of your select statements for it to work correctly. I built a data importation integration using it once and once I got tired of it breaking I just caved and rewrote the tool in C# and never had any more trouble. But none of that's what I'm talking about when I say that it feels like a second class citizen. If you're on a Unixy machine, every tool implicitly runs from within a shell. That means the shell is always available, even from an application. Not so with Windows. In Windows, the .NET API is your world ( or if you're unlucky, the Win32 API) on Linux, it's the shell. It's kind of in this sense that Powershell isn't really a shell in the sense that Bash is the primary interface to the operating system whereas Powershell is just an interface layered onto other interfaces. I've done enough sysadmin type work in either environment to feel the difference. Powershell is less a primary interface with the system and more a scripting language. As a scripting language, it's pretty fine, I have no complaints about the design. I'd like to think it's pretty close to what I would have come up with had I been tasked to design a CLI for Windows in the mid 2000s, but it doesn't underly the system as deeply as the Unix shells do. Edit: For an great concrete example, compare Cron with the Windows Task Scheduler. With Cron, the command language is whatever your shell happens to be. You have a string which specifies the schedule, followed by some shell command which does your task. The shell command can launch a program, start another script, or you might be able to contain it all in the single line. On Windows, you provide the exact path to the program you want to launch and any arguments. That's it. Powershell isn't available. If you want to launch a PoSH script, you have to reference the PoSH executable and provide your script as an argument. It's relatively ugly. One nice thing about the Cron approach, is that you can provide input redirection for ad-hoc logging or even output suppression, without having to modify your executable. It's a lot more steps to do the same thing on Windows.
- majkinetor 7y agoLets not dive into details here. I know that Sql Server module sux (MS guys I worked with told me that Sql team didn't quite get it), especially when it automatically changes drive to virtual one upon loading. But it works, once you know the quirks, or you can find alternative (number of them). > If you're on a Unixy machine, every tool implicitly runs from within a shell. Run Windows Core or Nano server and you have the same thing. Run X Windows and you have th same thing on Linux as on Windows. > Either the powershell AD module, which is incomplete and doesn't cover the entirety of Active Directory, or you resort to the native .Net API which is ugly and unintuitive when used from a command line. Many cmdlets are incomplete. Why do you think Linux CLI tools are complete ? Anyway, without any IDE and with just Notepad knowing a bit of .NET you could create yoru own functions where it isn't enough. I do it all the time, here is one link: https://github.com/majkinetor/posh https://github.com/majkinetor/posh About ugliness, my God bash is ugly. The code is so ugly that it hurts. I don't even have to translate the C# code in Powershell if I don't want, I can just compile it and execute it from the string from Powershell. Dropping to .NET was never ment to be used on command line - wrap it into nice sugarry function/module. > For an great concrete example, compare Cron with the Windows Task Scheduler. Great example, because I like Cron and I hate WTS. The problem is the syntax - cron syntax is easy to learn and remember. WTS can't be specified that easyly, in any case you need to click, use XML, use ughly CLI tools, or incomplete Task Scheduler cmdlets. Also, WTS is full of quirks. Yeah, typical way is 'here is exe, run it, thats it' or 'powershell -Command/-File' or 'cmd.exe -C ...' (as is with many other linux tools, cron excluded). Its easy enough to create scripts, for instance this is my replacement for Startup folder: https://github.com/majkinetor/posh/blob/master/MM_Admin/Register-LoginTask.ps1 https://github.com/majkinetor/posh/blob/master/MM_Admin/Regi... But there is something more in line with your desires - PowerShell Scheduled Jobs (not Tasks, Jobs) which work as you want it - Powershell itslef manages scheduling.
- astine 7y ago"Run X Windows and you have the same thing on Linux as on Windows." No you don't. X Windows is still run from a shell. The Windows GUI, by contrast, is not. Any application run in Linux or Solaris or whatever can drop down to the shell. And if I run an application from a terminal, I can take advantage of that. Not so with Windows. "Anyway, without any IDE and with just Notepad knowing a bit of .NET you could create yoru own functions where it isn't enough." I've written PoSH modules before. I'm pretty familiar with the process. I don't know what point you're trying to make. "Why do you think Linux CLI tools are complete ?" Because in the Unix environment, the CLI tools have been the primary admin interface for the past 40+ years. In Linux, the CLI comes first and the GUI is an afterthought. In Windows, it's the other way around. If you think that's changing, great. But I work on Windows in my day to day work, and regularly write Powershell so I've got a good feel for the difference.
- resoluteteeth 7y agoPowershell has fantastic integration with the system. In additional to be able to interact with .net and com directly, it is now the primary interface for administering server versions of windows.