Back to articles

Introduction to PowerShell

February 2023 | Stefan Anghel

What is PowerShell

PowerShell is a cross-platform task automation solution consisting of:

  • ‍Command-line shell: allows you to type commands directly into the shell interactively, execute them and see the results.‍
  • Scripting language and framework: can be used to create scripts, executable automatically or in callable interactively in the shell.‍
  • Ecosystem of modules: has a robust ecosystem of modules that allows you to use features and capabilities developed by third parties.These are created by Microsoft or third-party developers and can be installed from the PowerShellGallery or other online repositories.‍
  • Automation framework: allows Powershell to be used from within other applications.NET (System.Management.Automation)‍
  • Configuration Management Framework (via Powershell DSC- Desired State Configuration): enables automation of configuration management tasks for Windows-based environments, as well as other applications and services (Active Directory, SQLServer, Azure, AWS, VMWAre, Exchange, SharePoint, etc.).
  • For operating systems management, it is used in combination with other tools and technologies, such as:‍

  • Windows Management Instrumentation (WMI)
  • Common Information Model (CIM)
  • History of PowerShell

    PowerShell was created by a team of Microsoft engineers, led byJeffrey Snover, a senior systems engineer at Microsoft.

    Snover was the creator of the original Windows PowerShell project and continued to direct the development of the product throughout its life cycle. He worked for Microsoft for many years and helped develop several products and technologies, including Active Directory, Windows Server, and the Windows NT operating system. After the release of PowerShell Snover continued to work on the development and deployment of the technology: in fact, he worked on the creation of the cross-platform version PowerShell Core. He is currently the Chief Technologist of the Cloud+ AI Platform at Microsoft.

    Windows PowerShell was first launched in 2006as a Windows shell to automate administrative tasks. It was initially based on .NETFramework and used a proprietary scripting language called PowerShell Language. Over time, Windows PowerShell has continued to evolve, introducing new features and enhancements to make it easier to automate administrative tasks on Windows.

    In 2016, Microsoft announced PowerShell Core, a version of PowerShell that is designed to be cross-platform and uses .NET Core instead of .NET Framework. PowerShell Core is designed to be compatible with Windows, macOS and Linux platforms, allowing administrators to use the same tool on multiple operating systems. In addition, PowerShell Core was designed to be compatible with earlier versions of Windows PowerShell, meaning that scripts written for Windows PowerShell can run on PowerShell Core without modification.

    With the increasing popularity of using Linux and macOS operating systems in data centers, PowerShell Core has become an increasingly important tool for system administrators who need to manage mixed environments. With its cross-platform compatibility and ability to run Windows PowerShell scripts, PowerShell Core has become a powerful tool for automating administrative tasks across multiple operating systems.

    Differences between Windows PowerShell and PowerShell Core

    Windows PowerShell

  • Binary name: powershell.exe‍
  • Closed-source
  • Uses the .NET Framework
  • Available only on Windows operating systems
  • Has access to all .NET classes and APIs
  • It is preinstalled on Windows systems
  • Does not support multiple side-by-side versions on the same System
  • Script development also in WindowsPowershell ISE (deprecated)
  • PowerShell Core

  • Binary: pwsh.exe‍
  • Open-source
  • Uses .NET Core / .NET 5+
  • Cross-platform, so even Linux and macOS
  • Has access to a subset of the .NET classes andAPIs available in Windows PowerShell
  • Must be installed manually
  • Supports multiple side-by-side versions on the same system
  • Script development with Visual Studio Code, not supported by Windows Powershell ISE
  • Both Windows PowerShell and PowerShell Core support the same basic commands and use the same syntax.

    However, some cmdlets and features may not be available in PowerShell Core because of the differences between .NET Framework and .NET Core / .NET 5+.

    Key concepts of PowerShell

    Cmdlet

    The cmdlets (“small commands”) are the heart of PowerShell. They represent the individual commands that can be used to perform tasks.

    Written in PowerShell itself or any other .NET-supported language (C#, VB.NET, F#..), they provide a wide range of functionality, from managing files and folders to configuring system settings and managing users and groups.

    Pipelining

    Pipelining is one of the most powerful features of PowerShell. It allows multiple cmdlets to be linked together to create more complex operations or scripts.

    For example, a system administrator might create a list of all users in a specific group and then “pipe” (pass) the result to a cmdlet to disable the account of all users in that list.

    Object-oriented

    PowerShell uses objects to represent data and system resources. This means that data returned by a cmdlet is represented as objects and can be used as input for other cmdlets. This makes it easier to retrieve, modify, and produce data.

    Integration with .NET

    Finally, PowerShell is integrated with .NET, which means that administrators can use .NET Framework features and classes in their PowerShell scripts. This allows them to extend the functionality of PowerShell and adapt it to their own needs.

    Why learn and use PowerShell

    From the perspective of a software developer

    PowerShell is a very powerful tool for developers, primarily because it canautomate many repetitive tasks and efficiently manage system resources.

    Developers can use PowerShell to automate the configuration of a development environment, test execution and code deployment. In addition, PowerShell enables management of resources from Azure, AWS and other cloud services, simplifying the process of creating and deploying applications.

    PowerShell is a very flexible and powerful scripting language that enables the creation of complex scripts to automate administrative and systems management tasks.

    Based on .NET(Framework or later) technology, it allows developers to use the same libraries and features of .NET that they are familiar with. This makes it a very powerful tool for those already working with .NET, as it allows them to use their existing skills to automate administrative tasks.

    From the perspective of a systems administrator

    PowerShell is a powerful systems administration tool for Windows and beyond that enables administrators toautomate many repetitive tasks and perform administration tasks on multiple systems simultaneously.

    With PowerShell, administrators can write scripts to automate many tasks, such as creating users, managing groups, and configuring system settings.

    In addition, PowerShell offers an advanced command line interface (CLI) that allows administrators to quickly execute complex commands and access advanced Windows features. A systems administrator can create custom scripts to meet the specific needs of his or her organization.

    In summary, learning PowerShell can help administrators automate repetitive tasks, increase efficiency, and improve management of the systems they manage.