If you immerse yourself in Microsoft history for long enough, you’ll come across more than one story about staff trying to add more command-line features to its operating systems. The plans go up the corporate tree, to the rarified heights of a Bill Gates review, where the executives ask, “What part of the name Windows do you have a problem with?”
Corporate legends aside, Windows on both the desktop and server have long been the province of GUIs, point-and-click experiences driving everything from files on desktop PCs to managing entire virtual networks in the public cloud. That was all very well when you were dealing with tens of PCs and a handful of servers in an office. It even still worked for client-server enterprise applications or a small farm of web servers.
Now, however, we have the cloud; in its public, private, and hybrid guises. Automated system administration tools orchestrate our applications and manage our virtual machines in heterogeneous environments that mix and match operating systems and management philosophies. Infrastructure is now code, and the data center an operating system. What now for the GUI? It’s at heart a tool for one machine, one that needs an operator — not the automation that’s required for operations at scale.
From cmd.exe to PowerShell
Microsoft’s original command line, cmd.exe, wasn’t ready for this new world, offering just simple batch-command capabilities and basic scripting. That’s where PowerShell comes in. Building on .Net and lessons from Unix shell environments, it’s at heart a systems administration programming language.
PowerShell code uses C#-like constructs with long, self-descriptive commands. It’s not the terse Unix command line; it’s one where verbs and nouns combine in a grammar that is surprisingly easy to pick up. If a cmdlet doesn’t exist for what you want, combine several into a script or even write your own.
Now 11 years old, PowerShell has become not just a Windows tool but one that can run on most other systems. It’s also open source, with a thriving community. But it has not left its Windows roots behind, and it remains a key component in Windows’s systems management ecosystem. Drill down behind the System Center GUIs, and you’ll find the commands that you send are remotely executed PowerShell. Click an export button, and the scripts that System Center generates are ready for editing and reuse in your own infrastructure.
That option is an interesting one, because you’ve now got the tools you need to build your own runbook of scripts. Need to create and deploy Hyper-V virtual machines from a library? Push a VM using System Center Virtual Machine Manager, then export the PowerShell script, edit it, and save it for later use.
Generalizing PowerShell cmdlets is easy enough: Just replace explicit names of servers with variables and add code to parse calling strings to fill those variables. Once generalized, System Center PowerShell scripts are the building blocks for more complex actions, such as using a query against Active Directory to get a list of running servers and then using that list to modify network addresses to move an application to a backup network while a new release is deployed.
Getting PowerShell widely used has taken some time; there’s a steep learning curve that requires some programming skill. But once you’ve made that leap, the ability to manage many systems from one keyboard makes a big difference to working with modern application architectures. Extension libraries add cmdlets for Microsoft’s cloud services, including Azure and Office 365. PowerShell is also used to embrace new ways of thinking about administration, for example the Just Enough Admin approach that delegates rights only when needed and only for what’s required.
Bash for modern application development
Recent Windows 10 desktop releases have added support for Linux command-line tools, initially using Ubuntu in the Window Subsystem for Linux, exposed through the Bash shell. More distributions and alternative shells are coming, but Bash’s wide adoption make it an attractive route to bringing Unix tool chains to Windows. Ubuntu’s wide catalog of software, and its easy apt-get installation and update features mean you can quickly go from a bare prompt to a fully featured set of tools in a matter of minutes. SSL capabilities give you remote access to Unix servers, and Windows software is treated just like Linux binaries: Set a path so you can launch apps straight from the command line.
Bash is becoming an important piece of Microsoft’s developer outreach, making Windows accessible to the developers who’ve been using MacOS for its Unix tools. It’s soon to go beyond the desktop, with a Bash-based Azure command line in preview in the Azure web portal and in its new iOS and Android management apps. The Azure command line will also soon support PowerShell, with a simple dropdown menu for switching personalities on the fly.
Visual Studio Code gets a terminal
Microsoft’s open-sourced developer’s editor, Visual Studio Code, recently added an integrated terminal. By default, it uses your system’s preferred command line, but it’s easy to switch between cmd.exe and PowerShell, and even to open a Bash terminal if you’re running Windows Subsystem for Linux. The way we write and debug code is changing, and a terminal can help test not just Node.js applications but also explore containers or drive Git and other modern development tools.
Having access to a terminal inside an IDE has other advantages, beyond test and debug. It’s a way of connecting to other machines, giving remote access to GUI-less servers running Linux or Microsoft’s own Windows Server Core. It’ll even allow remote control of Nano Server installs. With much of the modern devops tool chain coming from the Linux world, direct access to your build engines, your deployment tools, and your source code repository is essential. Bringing Windows Subsystem for Linux into Visual Studio Code simplifies what could have been complex.
You’re not limited to a single terminal, so you can have one terminal running PowerShell for systems management of your local and cloud servers and one terminal running Bash for testing node apps or working with GitHub. It’s a flexible approach, and one that takes advantage of Windows’s newfound love of the command line.
We live in a world of many different computing models, all working together, all working at scale. Command-line tools like those in the latest Windows releases simplify both administration and development, giving access to a powerful cross-platform tool chain for working with the cloud and for taking advantage of modern devops processes.