Networking

PowerShell: The smart person's guide

This comprehensive guide covers essential PowerShell information, including features, usage requirements, and how Microsoft's framework extends to task automation and management.

03spgpowershell-a-smart-persons-guidehero.jpg
Image: Microsoft

PowerShell was developed 10 years ago by Microsoft to expand the power of its command line interface (CLI) by coupling it with a management framework that is used to manage local and remote Windows and Linux systems. By making use of the Component Object Model (COM), Windows Management Instrumentation (WMI), and Common Information Model (CIM) interface standards, PowerShell allows for managed elements of computing objects to be administered independent of manufacturer or provider.

For the latest information about PowerShell, check this "living" guide, which we'll update as Microsoft releases new information throughout PowerShell's development lifecycle.

SEE: Check out all of TechRepublic's smart person's guides (TechRepublic)

Executive summary

  • What is PowerShell? Microsoft's PowerShell is a management framework that combines a command-line shell and scripting language that is built upon the .NET framework.
  • Why PowerShell matters: PowerShell is capable of automating management tasks and functioning as a dedicated scripting language for Microsoft-based software. Also, PowerShell includes commands called cmdlets that add functionality to the core foundation.
  • Who PowerShell affects: Businesses relying on Microsoft and Linux services to empower their business functions, and the IT professionals that are responsible for managing this infrastructure.
  • When PowerShell is happening: PowerShell 5.1 is currently available as an update from Microsoft's website for Windows-based OSes, while Unix-based systems may clone or download the source code from GitHub.
  • How to get PowerShell: PowerShell is installed as part of all Windows client and server OSes. Also, Microsoft has made the source code available for use on Unix-based systems, including various Linux distributions and Mac OS.

SEE: Ebook: Saving time with PowerShell (Tech Pro Research)

What is PowerShell?

Released as PowerShell 1.0 on November 14, 2006, Microsoft developed PowerShell to address the shortcomings of its DOS-based CLI, particularly when managing objects using complex scripting languages.

By creating a new shell from the ground up, Microsoft effectively developed an extensible environment that would be powerful and flexible—it's capable of automating management tasks and functioning as a dedicated scripting language for Microsoft-based software.

Through various revisions, PowerShell has added modules to extend functionality to new objects as well as introduce new cmdlets for managing more resources, including Active Directory and Exchange Server. On August 18, 2016, Microsoft announced that PowerShell was going open source and provided its source code to the public, adding support to Unix-based OSes, including Linux distros and OS X.

PowerShell includes a number of cmdlets with which to manage objects—far too many to list here. Some of the most notable features, modules, and cmdlets include the following.

  • Active Directory (module): This module is used by PowerShell to extend management capabilities to Active Directory objects, including computers, users, and groups and attributes stored within accounts.
  • Exchange Server (module): This module is used by PowerShell to enable full administration of Exchange Servers. Included within the module are additional cmdlets that fully support all aspects of your Exchange email server.
  • Get-Help (cmdlet): This built-in cmdlet within PowerShell core provides helpful information, including syntax use and examples of commands and what they accomplish.
  • Get-Command (cmdlet): When executed, this built-in cmdlet within PowerShell core provides a list of commands that are available. It's useful in identifying which commands are available for each module.
  • Set-Variable (cmdlet): This built-in cmdlet within PowerShell allows the user to create variables used to store data, such as file paths, multiple objects, or snippets of code you wish to reuse.
  • Invoke-Command (cmdlet): This built-in cmdlet within PowerShell calls upon another cmdlet, usually run from a local computer, to execute the invoked command on remote computers.
  • Pipeline ( | ): One of the features of PowerShell is the ability to chain commands together by means of the pipe character. Piping commands causes PowerShell to run the first part of the command and then output the results for use by the second command and so on until the entire sequence is run. It is useful when performing a multiple-step task, such as creating a username, adding the username to a security group, and resetting the default password.
  • Function ( { } ): Similar to the pipeline feature in that cmdlets may be linked together, functions allow for greater control over the scripting process. By wrapping cmdlets in braces, a function is created that serves to run the sequence one or more times.
  • Out-File (cmdlet): This built-in cmdlet within PowerShell allows a command's output to be exported to a file. Typically used with the pipe feature, a user can get a list of user accounts that are disabled in Active Directory, for example, and export that list to a text file for future use.
  • Import-Module (cmdlet): This built-in cmdlet within PowerShell imports one or more modules into PowerShell to further its feature set, cmdlets, and functionality.

System requirements

  • Windows 10 Anniversary Update: PowerShell 5.1 is pre-installed.
  • Windows 10 or Windows Server 2016: PowerShell 5.0 is pre-installed.
  • Windows 8.1 or Windows Server 2012 R2: All required base components are included with these releases. Installing Windows Management Framework 5.0 will upgrade PowerShell to version 5.0.
  • Windows 7 SP1 or Windows Server 2008 R2 SP1: Windows Management Framework 4.0 must be installed prior to Windows Management Framework 5.0 to upgrade PowerShell to version 5.0.
  • Windows .NET Framework 4.5 (required)
  • Internet: Broadband access (optional)

Additional resources:

Why PowerShell matters

Until the release of Windows 95, Microsoft chose to run Windows over DOS since it was the de facto OS in use on IBM-compatible computers. From Windows 95 on, Windows kept MS-DOS since some legacy applications still relied upon it.

MS-DOS also served as the means of administering devices through remote methods and by way of scripts that would be coded to automatically run tasks that were deemed repetitive and time-consuming to manage Windows computers.

MS-DOS was released in 1981, and Microsoft did not evolve its CLI (unlike its Unix-based competitors) until the initial development of PowerShell in 2006. In making this 25-year leap, PowerShell was designed as more than just a CLI replacement.

Microsoft created PowerShell as a management framework that combines both a command-line shell and scripting language that is built upon the .NET framework that used as a software framework, primarily on Windows, to standardize code and develop powerful applications.

This results in PowerShell being able to not only be used to manage hardware, software, and network objects at the command line, but also allows programmers to use its scripting capabilities to interface with any manageable attributes to share data between them—even outputting this code through .NET to develop applications for one personal computer or scale it to large enterprise systems worldwide.

Additional resources:

Who PowerShell affects

PowerShell affects all types of users, from end users looking to be more productive to administrators seeking a simpler, more powerful solution to manage devices locally and remotely to developers writing their own applications to interface between hardware and software layers. PowerShell is the next step in Microsoft's CLI evolution.

Adoption rates are difficult to gauge at times, as PowerShell does require learning new commands, new syntax, and logic in order to reach its maximum potential. And yet, Microsoft is already bringing this point home through the use of PowerShell modules that serve to integrate with enterprise applications such as Exchange, SQL, and Windows Server to extend functionality and manageability.

More specifically, with applications like Exchange for example, while a lot of the management features are available via the GUI, in order to experience its full management capabilities, mail administrators will need to utilize PowerShell to accomplish many tasks.

Additional resources:

When PowerShell is available

PowerShell has been available for use on Windows computers since 2006. Beginning with version 1.0, PowerShell was made available to Windows XP SP2, Windows Vista, Windows Server 2003, and 2008.

PowerShell 2.0 was an upgrade to Windows XP SP3, Windows Vista SP1, and Windows Server 2003 SP2. It came integrated with Windows 7 and Windows Server 2008 R2.

PowerShell 3.0 was an upgrade to Windows 7 SP1 and Windows Server 2008 SP1 and 2008 R2 SP1. It came integrated with Windows 8 and Windows Server 2012.

PowerShell 4.0 was an upgrade to Windows 8, Windows 7 SP1, Windows Server 2008 R2 SP1, and 2012. It came integrated with Windows 8.1 and Windows Server 2012 R2.

PowerShell 5.0 is an upgrade to Windows 8.1, Windows 7 SP1, Windows Server 2008 R2 SP1, and 2012 R2. It comes integrated with Windows 10 and Windows Server 2016.

PowerShell 5.1, which is the most recent version, is currently only available via the Windows 10 Anniversary Update.

Additional resources:

Some alternatives to PowerShell

How to get PowerShell

PowerShell is integrated on all versions of Windows going as far back as Windows 7. It is also integrated on all versions of Windows Server going as far back as Windows Server 2008 R2.

Previous versions of Windows can run PowerShell; however, it is available as an optional update and not integrated with the operating system as is the case in more recent versions.

To install or upgrade to the newest versions of PowerShell, the Windows Management Framework (WMF) installer must be downloaded. The version number on the WMF installer directly matches the version of PowerShell that will be installed. Currently, WMF 5.0 exists and may be downloaded from Microsoft's website free of charge for Windows users.

For users of Unix-based systems, such as OS X and Linux, obtaining the latest version of PowerShell requires downloading the source code or cloning it from Microsoft's GitHub repository.

Additional resources:

How to use PowerShell

TechRepublic has published a number of tutorials on how to get the most out of PowerShell. Check out these tips, as well as some PowerShell basics from Microsoft.

About Jesus Vigo

Jesus Vigo is a Network Administrator by day and owner of Mac|Jesus, LLC, specializing in Mac and Windows integration and providing solutions to small- and medium-size businesses. He brings 19 years of experience and multiple certifications from seve...

Editor's Picks