PowerShell as a First Option
Mar 24, 2018
Curtis Alexander

I am always searching for a better way to unify the scripts I write for my home computer(s) with those I write for my work computer. At work we utilize Windows whereas at home I utilize macOS or a flavor of Linux. Typically, I think about how I can get scripts that I have written for *nix-like platforms to work on Windows. A couple methodologies I have explored include

  • Cygwin
  • Git for Windows
    • Includes bash and some light utilities for simple scripting
  • xonsh
    • I’m still quite interested in xonsh however it requires a proper Python environment be setup on each system. With the advent of conda this has become much easier, particulary on Windows. But distributing scripts widely at work is a challenge for those who don’t make use of Python.
  • Using a programming language that compiles to multiple platforms
    • Preferably one that produces self-contained binaries
    • Free CI services, like AppVeyor or Travis CI may need to be used to produce the actual binary
    • I had explored a few different languages. Note that each of these are particularly interesting because of the opportunity for advanced language features such as the strong typing in Haskell or FSharp or the macro capabilities in Racket.

None of the above are very satisfactory (for a variety of reasons). But recently I learned that there is a version of PowerShell — called PowerShell Core — that is built on top of .NET Core which itself is multi-platform. Thus my thinking has flipped! Instead of trying to bring *nix-like tools to Windows, maybe I should look to bring a historically Windows-like tool to *nix1.

Thus, I think it worth exploring the use of PowerShell as a cross-platform scripting language. After a cursory look at PowerShell, I know that I can pass around scriptblocks (lambda-like things) and make use of pipelines. With those primitives, the ability to create functions, as well as an assortment of data types (unlike bash where the principal data types are text and an array whose sytnax I never can remember) I should be able to begin to build up a small toolset that works on multiple platforms.

Maybe I found my solution!


  1. Why not just utilize the Windows Subsystem for Linux (WSL)? That would be ideal! The answer has more to do with my role at work than using WSL as a technical solution. My role is a strange mix of developer, business analyst, data analyst, person-who-knows-things-about-models, and manager. The tools that are available to me tend to be those that a business analyst or data scientist would utilize (or be permitted to utilize). Unfortunately, we have need to build up solutions that glue applications together and thus the need to utilize developer/scripting tools. A longer treatise on the need for business users to build out their own tool sets would make a good future post.