PowerShell is a command-line shell and scripting language developed by Microsoft for the Windows operating system (OS). It is used by IT administrators to automate tasks, manage file systems and control applications that run on Windows.
A beta version was first introduced by Microsoft in 2003 called “Monad.” It was renamed Windows PowerShell on April 25, 2006 and integrated with Windows 7 SP1 and Windows Server 2008 R2 SP1. It now comes pre-installed on all new releases of Windows OS and Windows Server. PowerShell versions 1.0 to 5.1 run on Windows-only client and server platforms and the .NET framework.
PowerShell Core is an open-source, cross-platform version that runs on top of .NET Core. The first version of PowerShell Core was released August, 2016 as part of PowerShell 5.1. It can run on Windows, Linux or macOS platforms.
If you are new to this versatile management framework and want to get started implementing it here are five basic steps on how to use PowerShell:
- Decide what version of PowerShell you want to use.
- Perform setup and installation.
- Learn how it works.
- Launch the PowerShell console.
- Write and run scripts.
Step 1: Decide What Version of PowerShell You Want to Use
Currently, there are six versions of PowerShell and each has different operating system or server requirements. Newer versions have limited backward compatibility with earlier versions. Service packs are available for some that can be used to upgrade. For example, PowerShell 3.0 can be added to Windows 7 or Windows Server 2008 using Service Pack 1 (SP1).
PowerShell Version | Release Date | Pre-installed OS/Server |
---|---|---|
PowerShell 1.0 | November 2006 | Windows 7, Windows Server 2008 R2 |
PowerShell 2.0 | October 2009 | Windows 7, Windows Server 2008 R2 |
PowerShell 3.0 | September 2012 | Windows 8, Windows Server 2012 |
PowerShell 4.0 | October 2013 | Windows 8.1, Windows Server 2012 R2 |
PowerShell 5.0 | February 2016 | Windows 8.1, Windows Server 2012 R2 |
PowerShell Core 6.0 | January 2018 | Free, open-source, cross-platform |
Version 2.0 has known security issues and Microsoft has recommended that enterprises stop using it. Removal of PowerShell 2.0 is in process. More robust security protections were included with later builds.
Step 2: Perform Setup and Installation
To start, find the version of PowerShell that is pre-installed on your Windows server or client computer. You can find this information by typing “$PSVersionTable” into a PowerShell console (PowerShell.exe) or ISE (PowerShell_ise.exe), then click “ENTER.”
Beginning with PowerShell version 3.0 released in 2012, you can upgrade to a new version using Windows Management Framework (WMF). Here is a list of WMF installers, what version of Windows and PowerShell they are used with, plus a link to the download page:
- Windows Management Framework 3.0 – Use to install PowerShell 3.0 on Windows 7 SP1 or Windows Server 2008 R2 SP1. Download WMF 3.0
- Windows Management Framework 4.0 – Use to install PowerShell 4.0 on Windows 7 SP1, Windows 8, Windows Server 2008 R2 SP1 or Windows Server 2012. Download WMF 4.0
- Windows Management Framework 5.0 – Use to install PowerShell 5.0 on Windows 7 SP1, Windows 8, Windows Server 2008 R2 SP1, Windows Server 2012, Windows 8.1 or Windows Server 2012 R2. Download WMF 5.0
- Windows Management Framework 5.1 – Use to install PowerShell 5.1 on Windows 7 SP1, Windows 8, Windows Server 2008 R2 SP1, Windows Server 2012, Windows 8.1 or Windows Server 2012 R2. Download WMF 5.1
To install PowerShell Core 6.0 on Windows, Linux or macOS, download from GitHub.
Step 3: Learn How It Works
Windows PowerShell Integrated Scripting Environment (ISE) uses a scripting object model. The design incorporates elements from many programming environments. A few key concepts of PowerShell are:
- Object manipulation commands – cmdlets are designed to deal with objects, not strings of characters.
- Extensible family command – can add cmdlets using snap-in to the shell or other cmdlets.
- Console input and display – processes command-line input directly.
- Uses some C# syntax – features and keywords are similar to C# programming.
The native binary commands used in PowerShell are called cmdlets. These are lightweight commands that can be created from a few lines of code. More than one hundred core cmdlets are included in the shell – or you can write your own.
To learn cmdlet classes, processing methods, attributes, names and how to write cmdlet code click here: Cmdlet Overview.
Step 4: Launch the PowerShell Console
To launch a PowerShell session using the console in Windows click on the Windows key, type PowerShell then click on Windows PowerShell. Or click start, go to All Programs, select Accessories, select PowerShell, right-click on PowerShell then select “Run as Administrator.”
You can also open a command-shell window and type “powershell” or type “powershell_ise.exe” in the Run box.
Step 5: Write and Run Scripts
PowerShell is able to execute four types of named commands: cmdlets, PowerShell scripts (suffix .ps1), PowerShell functions and standalone executable programs. Scripts are used to access Windows methods and properties.
A detailed, step-by-step description of how to create, edit, run and save scripts using PowerShell is here: How to Write and Run Scripts in the Windows PowerShell ISE.
Above are five easy-to-follow steps to help you get started using PowerShell. It can be used for a multitude of administrative tasks in conjunction with Microsoft Windows OS or Server.