Microsoft Open Sources PowerShell, Ports the CLI to Linux
Microsoft has opened sourced its Windows command line shell for administrators, called PowerShell, and has ported it to Linux and MacOS.
“PowerShell on Linux now enables customers to use the same tools, and the same people, to manage everything from anywhere,” wrote Jeffrey Snover, who is a Microsoft technical fellow and lead architect of the company’s Enterprise Cloud group, in a blog post, announcing the release.
Like Bash for Unix/Linux, PowerShell was designed to be the rich command line interface for Windows Server. It was built on the .Net framework, so it enjoys a rich scripting environment.
Going forward, new versions of PowerShell will be released simultaneously for Windows and for Linux, Snover told TNS in a follow-up interview. “Linux will be a full first class citizen,” he said.
The work is based on earlier and Microsoft port of .NET Core to Linux. The code is available on GitHub. Packages will be initially available for Ubuntu, CentOS, Red Hat Enterprise Linux, and Mac OS X. The company has also ported OpenSSH to run on Windows, so users can deploy a single remote access protocol for all uses of PowerShell.
The impetus for opening sourcing the CLI came from customers who, according to Snover, came from customers who wanted to standardize on PowerShell, but were limited because it would not run on Linux.
PowerShell can not only offer an interface to Windows and Linux but also can be extended to third party platforms, by way of modules. Amazon Web Services and VMware both have PowerShell extensions available, and Google and Chef are in the process of developing them as well.
“Customers will be able to write a script to manage VMware, Azure or AWS, and run it on Windows, MacOS or Linux, without modification,” Snover said.
Backslashes and Case Sensitivity
Microsoft originally developed PowerShell with Unix in mind. The company wanted a powerful command line interface (CLI) for Windows much like Unix’s many shells offered, that administrators could use to control applications and script processes.
While the development team, of which Snover was a part, wanted to mimic Unix, it took a slightly different approach. Part of the power of Unix/Linux is how, at the command line, all actions can be scripted and tethered together in a pipeline of actions.
The Unix pipeline was built around text strings, while PowerShell was optimized more for objects, Snover said. The current development team still has some work to get up to full fidelity for text stream-based processing, Snover admitted, as well as with other advanced Unix shell approaches like globbing, which is a form of file name expansion.
On the other hand, PowerShell’s object-based approach might bring some advantages that Bash may not (In March, Microsoft embedded Bash onto Windows). “Where we shine is in structured data,” Snover said.
For purposes of automation, the administration world is moving away from text stream processing, for duties like reading configuration files, and moving towards surfacing structured objects, such as REST APIs, Snover said.
“Call a REST API and what you get is a JSON file. We convert them to structured objects,” he added.
Of course there are some aspects of Linux that Windows admins must adjust to, most notably the case sensitivity, which Unix respects while Windows doesn’t. Then there is also the differing nature of how Unix and Windows handle slashes to distinguish file paths: Unix uses forward slashes and Windows uses backward slashes. Those interested in writing cross-platform scripts must still take these differences into account, Snover said.
The company also has added a number of new features to help with cross compatibility. One is the PowerShell Editor Service, which provides the hooks for external code editors to edit PowerShell files, complete with support for IntelliSense, and other debugging tools. Initially, VS Code and Sublime are equipped for PowerShell, with more editors to come.
The company has also built in OpenSSH support for PowerShell, allowing users to SSH into remote PowerShell environs using the PowerShell Remoting Protocol (MS-PSRP). In effect, Microsoft has ported OpenSSH to Windows. Users can also deploy the existing Windows Remote Management Support.
Manage all the Things
While extending the CLI to other platforms may seem like a pleasant feature, the move has potential powerful repercussions. Running on both Linux and Windows, PowerShell could now “provide a common management stack across all the things that need to get managed,” Snover said.
For instance, it could be used to power up VMware VMs, configuring them as they are deployed. The PowerShell VMware module has commands for every action one can take in vCenter.
PowerShell is key to using Microsoft’s Desired State Configuration (DSC), the company’s IT automation scripting language that can be used for configuring and managing resources. PowerShell also provides an interface for the company’s cloud management service, Operations Management Suite (OMS), which provides visibility and control of workloads across Azure and other clouds. In effect, this allows users to manage their cloud resources from the command line.
OMS also provides a central location to manage PowerShell runbooks, DSC configurations and DSC node configurations from one place.
I think it is the right thing to do for Microsoft in terms of continuing to build on the success and adoption of PowerShell,” wrote Al Hilwa, IDC program director for software development research, in an e-mail. “In fact, it could be argued that it is hard to further build ecosystem and community for any proprietary technology which is targeted at least in part at developers. It is time to make [PowerShell] available on Linux systems which account for most of what is running in the cloud today.”
Feature Image by Jorge Lascar, CC BY 2.0.