Powershell Everywhere

This article is part of a series about powershell in general and the multiplatform nature of Powershell-Core specifically.

  1. Powershell Everywhere
  2. Multiplatform Setup for Powershell

In my day job I work for a company focused on Windows/.NET/WPF. While we worked on cleaning up our build processes and standardize our tools over all our projects, I had the chance to play arround with multiple script languages. One that is following me around for a while now is Powershell.

Technical Reasons to look into Powershell

Our 'legacy' apps mostly used rake or even good old batch files. As we mainly code in C#, I proposed Cake as our build tool. This naturally forced us to use Powershell, because the standard way of using Cake under Windows is a Powershell bootstraper. In a later part of the refactoring of our toolchain, I got a chance to write a bigger test suite in Powershell. This worked well, as Powershell is the standard windows shell today, and therefore greatly supported.
On another occasion we had to provision some VMs as build agents. Here another tool came in handy:
Chocolatey - This package manager written in Powershell finally made something possible that was one of my biggest painpoints of working in Windows, the long setup time when working with a fresh machine. This gets even easier when using Boxstarter which is build on top of Powershell and
Chocolatey. At this point I was locked into Powershell while working on windows.

Stylistic Reasons to use

Things I instantly liked about Powershell is its standard naming convention. <Verb>-(<SomeAddition>)<Noun>. It shows you what the normal return of Powershell functions is: An object. While I was confused for a while on how to get certain property values out of objects and when some path would be implicitly converted to a string or not, that was mostly due to me not reading docs.
At this point the New Microsoft Documentation has to be highlighted. The guys in Redmont took most complaints people had about MSDN and created an actual useful documentation with great focus on fast tutorials and working examples.

Shells on other Plattforms

Though I mostly work on windows, I use docker a lot and all my server apps these days run under linux. Back when I went to university I played around a lot with linux and always liked aspects of it. What I never liked was the missing consistency between the tools you have to use every day. While the linux shells work well communicating over plain ASCI text, the in-/outputformats are not consistent between tools. This means the overhead of connection tools can be huge.
I'm not a linux expert and certainly not a bash or sh one. Personally I used zsh when working under linux for years. This is changing because of microsofts effort to implement a cross platform toolchain.

Powershell Core enters the Stage

The first alpha release of Powershell Core went up mid year 2016. I shortly after that heard of the project and nearly fell of my chair. .Net on linux is one thing. The 'Windows-Shell' under linux sounded crazy at first. Since then 2 years have past and dotnet core is an actual thing and Powershell is not the 'Windows-Shell' anymore. You can use PWSH, as the tool is actually called, under every mainstream linux distro.
One other huge upset is performance. As Powershell Core is built on dotnet core there is a big performance uptick. In every other way powershell on linux is just like every other shell. In contrast to windows powershell the huge number of alias definitions for Cmdlets hash been removed though, as they would colide with native linux functions.

One shell config for every system

The number one reason for me to switch to powershell was that I can reuse my shell configuration on windows. To this point I didn't find any module of my configuration that isn't ported to Powershell Core yet.
The feeling to log into a linux machine and not noticing any change in my command prompt was kind of unreal. And I really look forward to being able to use the same shell config on every system.

Bottom Line

I would recommend to give powershell a chance, even if windows isn't your main OS. It's standardized Cmdlet syntax is very convenient for teams and the biggest downside, it being windows only, is finally history. The object orientated nature of the function returns is also very helpful to reason about the code written.

Resources

Finally here is a short list of resources I use often when using Powershell:

Thanks for your time and feel free to contact me with any questions or feedback.