Affiliate Disclosure: By buying the products we recommend, you help keep the lights on at MakeUseOf. Read more.
Most users have never heard of PowerShell, let alone touched it and tried it out. This is perhaps because of the name, which sounds like something only used by hardcore IT geeks. Or perhaps because the benefits of PowerShell are unclear. Maybe it’s because of the initial learning curve.
Truth is, yes, most casual computer users won’t need the power of PowerShell. But if you have any programming experience at all, or if you prefer the command line over graphical windows, or if you love to automate tasks using scripts, then you’ll love what PowerShell can offer.
In short, PowerShell is what you’d get if you crossed the Command Prompt with Batch Scripting, threw in some extra features, and kicked it all up several notches. Intrigued? Here are several solid reasons why you should try it.
1. PowerShell Scripting Is Improved
Like batch scripts, PowerShell scripts are just lines of instructions written to a plain-text file, except the file uses a .PS1 extension instead of a .BAT or .CMD extension. But that’s pretty much where the similarities end.
Batch scripts have one huge limitation: the only commands available to you are the commands you can use in the Command Prompt. Or in other words, a batch script is just a series of Command Prompt commands (with some conditional logic thrown in). This is fine for primitive tasks and simple automation, but a real hindrance when you want to do something complex.
On the other hand, PowerShell scripts are written using the PowerShell scripting language, which is a real programming language that’s capable of elaborate logic for truly advanced tasks. The language itself is simple to learn, especially if you have programming experience, but it supports variables, functions, loops, exception handling, and more.
One more thing to note here is that PowerShell ISE (Integrated Scripting Environment) is much improved over regular Command Prompt. It has a few nifty quality-of-life features that come in handy when writing your scripts, such as syntax highlighting, autocompletion, tabbed editing, and context-sensitive help.
All in all, not only does PowerShell allow you to write better scripts, it allows you to write them faster.
2. PowerShell Supports the Full .NET API
The bulk of PowerShell’s capability and flexibility comes from its integration with the .NET Framework. Every PowerShell command (called a cmdlet) is actually a .NET class that gets invoked at runtime, which simply means that cmdlets can be written in any .NET language (which, as of this writing, include Visual Basic, Visual C++, and C#).
So what’s the benefit of .NET API support?
Well, the .NET API is packed full of amazing utilities and functions that are organized as a set of standard class libraries. You can tap into these aspects of the API to help you do things like gather inputs or manage data without having to rewrite all of those helpers yourself.
PowerShell, in conjunction with the .NET API and various providers that come built into PowerShell itself, also allows you to tap into the deepest parts of the Windows ecosystem, including the filesystem, the registry, and the certificate store. As such, PowerShell cmdlets and scripts can do so much more than batch scripts.
And perhaps most interesting is that PowerShell lets you pipe the output of one cmdlet as the input to another cmdlet as objects. Most other shells, including Bash, can only pipe information from one command to another as plain text. PowerShell’s method is cleaner, tighter, and less prone to errors.
3. PowerShell Can Run Batch Scripts
If the above reasons haven’t convinced you, then I believe this one will.
PowerShell isn’t built on top of Command Prompt. The two shells are completely different with separate underlying architectures, so it’s technically wrong to think of PowerShell as “Command Prompt 2.0” or what have you. However, PowerShell is designed to be backwards-compatible.
Most of the common commands you’d use in Command Prompt can be used in PowerShell. Under the hood, PowerShell actually has built-in cmdlet equivalents that were scripted to do exactly the same things as those commands, but uses aliases to “connect” the old command names to the new cmdlets.
For example, when you run cd in PowerShell, you’re actually running the Set-Location cmdlet. In this case, “cd” is just an alias for “Set-Location” and this makes life easier for you. Similarly, when you use rename in PowerShell, it’s secretly running the Rename-Item cmdlet.
And so, unsurprisingly, you can run batch scripts within PowerShell, which means you can transition from batch scripting to PowerShell scripting without having to drop everything cold turkey.
4. PowerShell Is Microsoft’s Intended Future
PowerShell first debuted back in 2006. Now, over a decade later, it has risen to become one of Microsoft’s most important projects. The team behind it is working hard to make it the best shell it can be and Microsoft is really doing its utmost to push its adoption, especially among IT professionals.
Going forward, PowerShell is going to be the main method for automating tasks and applications in Windows and Microsoft enterprise products. It’s such a serious move that even third-party vendors have started to provide PowerShell libraries to help manage and troubleshoot their software.
But most importantly, Microsoft has been increasing the number of PowerShell-related questions that are asked in some of their certification exams. In fact, according to a 2009 interview in TechNet Magazine, Microsoft said that “the single most important skill a Windows administrator will need in the coming years is proficiency with Windows PowerShell.”
So whether you’re just an advanced home user or an IT specialist who manages Windows systems, it’s time to accept that batch scripting is obsolete and PowerShell is the future.
5. PowerShell Can Be Used on Linux
Over the last few years, Microsoft has made a number of surprising moves related to the realm of open source software. In 2014, they open sourced the .NET Framework and made it available across multiple platforms. Then in 2016, they natively integrated the Bash shell into Windows 10.
And in 2017, PowerShell became easier than ever to install on Linux. As of this writing, Microsoft now has package repositories that you can use to install PowerShell Core on most mainstream versions of Linux. If your system supports apt-get or yum, then you can most likely install it hassle-free. If not, you can still use the old installation instructions.
Why is this good news? Because your PowerShell knowledge won’t be limited to one operating system anymore. Batch scripts can only run on Windows (or through Wine on Linux, which we don’t recommend) so it’s restrictive, whereas PowerShell can now be helpful in broadening your expertise.
Getting Started With Windows PowerShell
Convinced yet? If not, that’s okay. As I said above, PowerShell isn’t for everyone, and if you’re happy enough using batch scripts for personal use, feel free to keep using them. But if you want to stay on top of evolving technologies and if you intend to become a certified IT specialist, learning PowerShell is more a matter of when, not if.
If you do want to get started, then start with these basic PowerShell commands which are simple and straightforward. Once you grasp those, continue on with these tasks you can automate with PowerShell and learn how to handle PowerShell errors. That should be enough to get you started.