cat posts/2016-08-23-powershell-on-linux.md

PowerShell on Linux and the end of the OS wars

· 2 min read · microsoft linux tools

In 2009 I wrote on this blog, with a straight face, that my OS of choice was Vista. I’d like that on the record before I say anything else.

Last Thursday Microsoft open-sourced PowerShell, under the MIT license, on GitHub, and put out alpha builds for Ubuntu, CentOS and macOS. Jeffrey Snover, who’s been PowerShell’s architect since it was called Monad, said the goal is for people to use the same tools to manage everything from anywhere. About two weeks before that, the Windows 10 Anniversary Update shipped with Bash on Ubuntu on Windows, an actual Ubuntu userland running Linux binaries unmodified, in beta behind developer mode. .NET Core 1.0 came out in June and runs on all three. SQL Server is coming to Linux.

When I became an MVP in 2005, it hadn’t been long since Microsoft’s CEO had called Linux a cancer. If you’d told me then that in 2016 I’d be running apt-get on Windows and PowerShell on a Mac, both from Microsoft, I’d have assumed you were joking, or about to try to sell me something.

I installed the macOS build on Friday. It’s very alpha. Plenty of cmdlets are missing, including anything that talks to Windows-only things like the registry. But the core idea works, and it’s still the thing I like most about PowerShell: commands pass objects down the pipeline, not text. Get-Process | Where-Object CPU -gt 100 | Sort-Object CPU doesn’t need anyone to know which column of ps output the CPU is in, or which flags your ps takes. Sooner or later every Bash script I write ends up doing fragile things with awk and cut, and I’ve always wanted that idea on Linux.

Will Linux people use it? Mostly no, I’d guess, and I don’t blame them. Bash is fine and everybody knows it, and PowerShell is verbose in a way I’ve grown fond of and most people find exhausting. It’ll matter more for people like us, who run a mix. We have Windows boxes and Linux boxes and engineers on Macs, and right now our automation is a pile of Bash scripts and a smaller, separate pile of PowerShell scripts that do some of the same things. One language for both would be nice, if it gets to beta.

The rough edges are getting found fast, too. Daniel Stenberg, who maintains curl, opened a pull request on the first day removing the curl and wget aliases that PowerShell has had on Windows for years, which point to Invoke-WebRequest, a completely different command with completely different arguments. It’s a fair complaint, and exactly the kind that only gets made once your code is public.

I use Windows, macOS and Linux every day, and have for a few years now, mostly because each one is best at something. For most of that time it felt like I was choosing sides three times a day. This month it feels a bit less like that.