Getting Started with PowerShell

Note: This guide is designed for beginners. If you're already familiar with scripting or command-line interfaces, you might find some sections basic.

Welcome to the official Microsoft Developer Network (MSDN) documentation for Windows PowerShell. PowerShell is a powerful task automation and configuration management framework from Microsoft, consisting of a command-line shell and a scripting language. It's built on the .NET Framework and is designed for system administrators and power users to control and automate system administration of both Windows and non-Windows operating systems.

What is PowerShell?

At its core, PowerShell is an object-oriented shell. Unlike traditional shells that deal with text streams, PowerShell works with objects. This means that the output of one command can be directly used as input for another, preserving its structure and properties. This makes it incredibly efficient for managing complex systems.

Key features of PowerShell include:

Launching PowerShell

To begin your journey with PowerShell, you first need to launch the application.

On Windows:

  1. Press the Windows key + R to open the Run dialog.
  2. Type powershell and press Enter, or click OK.
  3. Alternatively, search for "PowerShell" in the Start Menu. For administrative privileges, right-click on PowerShell and select "Run as administrator".

On macOS and Linux:

PowerShell Core (PowerShell 7+) is cross-platform. You can install it following the instructions on the official PowerShell GitHub repository. Once installed, you can launch it from your terminal by typing pwsh.

Your First PowerShell Commands

Let's try some basic commands to get a feel for PowerShell. Open your PowerShell console and type the following commands, pressing Enter after each one.

Getting System Information

To get information about your computer, use the Get-ComputerInfo cmdlet.

Get-ComputerInfo

To view running processes, use Get-Process.

Get-Process

Working with Files and Directories

PowerShell can interact with the file system just like other shells.

To list items in the current directory:

Get-ChildItem

This is equivalent to ls on Linux/macOS or dir in CMD.

Important: PowerShell cmdlets often follow a Verb-Noun naming convention (e.g., Get-Process, Set-Location, New-Item). This makes it easier to discover and understand their purpose.

Understanding the Pipeline

The pipeline is one of PowerShell's most powerful features. It allows you to send the output of one command as input to another.

For example, let's find all processes named "explorer" and select only their ID and Name properties:

Get-Process -Name explorer | Select-Object Id, Name

Here, Get-Process retrieves the process objects, and the pipe symbol (|) sends these objects to Select-Object, which then extracts the specified properties.

Next Steps

This was a brief introduction. To continue your learning, we recommend exploring the following resources:

Tip: Use the Get-Help cmdlet to learn more about any PowerShell command. For instance, to get help on Get-Process, type Get-Help Get-Process.