Windows PowerShell is what you get when you beef up C:\ prompt.
Developed for purposes of task automation and configuration management, Microsoft has been putting full weight behind making PowerShell the management tool of choice since its rollout in November 2006.
In point of fact, nearly all newer Microsoft server products require PowerShell, and there is a vast number of management tasks that can't be executed without delving into the command line. Bundling together the command line's speed, a scripting language's flexibility and the powerful capabilities of a GUI-based administrative tool, Windows PowerShell is designed from the ground up to deliver massive control over the Windows operating system while remaining easy to use.
Whether you're C:\ prompt’s biggest fan or strictly a GUI user, learning to use Windows PowerShell as an IT admin can save much of the effort you usually spend on common Windows admin tasks and kill those tedious, repetitive file management chores that eat up your time day in, day out (besides, it just looks cool to tackle your daily operations from the command line).
Curious to peek under the hood? Here is what you should know about PowerShell (and why you’ll love it).
What is Windows PowerShell?
Before diving into the essentials of Windows PowerShell, let’s first define what a shell actually is (no, we're not talking about crabs).
In computer science, a shell is a software program granting access to various services of an operating system. More technically, a shell is a text-based, command-line interface (CLI), meaning you can type commands to execute programs, open and browse directories or view processes that are currently running. Since the shell is only one layer above the operating system itself, you can perform operations that would otherwise only be possible to a limited extend (or not possible at all) via the GUI.
Compatible with the .NET framework, Windows PowerShell is a task automation resource including a command-line shell and a scripting language that enables administration in Windows systems. At bottom, think of it as a massive upgrade to the common Windows command prompt you’re already familiar with: While PowerShell can execute a good many of the same tasks - navigating the system, interacting with files, changing properties - it opens up the entire .NET framework capabilities for maximum power.
And that’s where the real fun starts.
Create your own commands and scripts with PowerShell
Simply put, PowerShell allows you to create your own commands and scripts. While PowerShell does come with an initial set of off-the-shef commands, you can easily add your own commands by creating cmdlets.
Essentially, cmdlets are the heart and soul of the PowerShell environment. Based on C#, a PowerShell cmdlet is a compiled piece of .NET code (more precisely a single class), which is expressed as a verb-noun pair with a .ps1 extension. Cmdlets have no direct representation in the file system and, when called up, are executed solely within PowerShell.
As both PowerShell and C# are integrated with the .NET framework, you have access to a comprehensive library of Microsoft-provided code along with an ample number of pre-existing functions and tools you can utilize to create your own cmdlets with minimal effort (to query all available cmdlets and functions, try Get-Command). Like to pull process information? Database connectivity? Network communications? Happily enough, the .NET framework provides all of that, so you don’t have to do the hard work - you just need to fit everything together by calling the right functions.
Why you will love PowerShell
PowerShell is packed with power and flexibility, granting you control of nearly every aspect of the Windows system. It does comes with a flipside, though: a learning curve (as there is with most scripting languages). Fortunately, PowerShell isn’t that hard to grasp.
Start small. Once the basic concepts sink in and you get over the initial hump, you will love looking at your daily admin tasks with your new PowerShell glasses on. Here is why:
1. PowerShell is both a command-line shell and scripting language
There is no need to compile code: Make use of existing PowerShell commands or scripts at the shell - right out of the box. Come up with your own code at the command line before you develop a function or script around it. Create quick and dirty cmdlets for once-off use only or write formal, readable scripts that will automate the execution of your admin tasks and keep them up and running for years.
The cost of this investment? Delving into PowerShell. Assuming you work with the Microsoft ecosystem on a daily basis as an IT admin, it’s fairly reasonable, considering you will likely need to learn PowerShell at some point or the other anyway (regardless of your preferred scripting language).
2. PowerShell is object-based
The key to PowerShell, in addition to the standardized naming and other features which make it such a handy tool, is the fact that many of the cmdlets are object-based: Sort, group, filter, measure, compare or take other actions on objects while they pass through the pipeline. Instead of working with raw text, work with properties and methods, rendering it quite simple to tie together commands and data across different technologies.
3. PowerShell works with a dizzying number of technologies
PowerShell integrates with the .NET framework, the Registry, COM, WMI and ADSI. SharePoint Exchange, Systems Center, Hyper-V, SQL. VMware vCenter, Cisco UCS, Citrix XenApp and XenDesktop. REST APIs, XML, CSV, JSON, Excel and other Office applications. Websites. C# and other programming languages, DLLs and further binaries including *nix tools.
4. PowerShell provides detailed process information
Let’s be blunt here: It surely is one thing to use an alternative task manager (and there is nothing wrong with it), but PowerShell offers some neat hacks as far as process management is concerned. Start with the native Get-Process and Stop-Process cmdlets to wrap your head around it.
5. PowerShell performs remote and background jobs
As all cmdlets can be executed as background processes, you can easily perform multiple tasks at once asynchronously. Also, PowerShell allows you to work remotely without using Remoting or WinRM: Cmdlets with remote capabilities have a -ComputerName parameter that allows you to execute cmdlets on any computer running PowerShell without using PowerShell remoting (even if the computer is not configured for PowerShell remoting).
6. PowerShell is future-proof
It’s a safe bet: PowerShell is here to stay. It has become a steady requirement in the Microsoft Common Engineering Criteria, and no server product is shipped without a PowerShell interface. In many instances, Microsoft builds the GUI management consoles for its products upon PowerShell, and a significant number of tasks can only be completed in PowerShell.
The bottom line? In case you haven’t already done so, dare to take a leap into the world of PowerShell – now is the right time.
For a jump start, try the Microsoft Virtual Academy. MVA offers a series of PowerShell-related courses for free - including a Getting Started course and Advanced Tools and Scripting course. Both courses contain 9 lessons that are each around 1-hour in length. If you fancy to dive even deeper, have a look at Microsoft’s PowerShell Survival guide - definitely a must read (and our hot tip) for PowerShell newbies and old hands alike.
Windows PowerShell cares about task automation to make your IT admin life a whole lot easier. We at Templafy do, too. Reach out to our Commercial Product Manager Jesper Petersen to have a chat and learn how we can help.