Getting Started with PowerShell
Welcome to the world of PowerShell! This guide will help you install, configure, and begin your journey with this powerful command-line shell and scripting language.
What is PowerShell?
PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and the accompanying scripting language built on the .NET Framework. It's designed for system administrators and power users to manage Windows, and increasingly, other operating systems like Linux and macOS.
Key Concepts
- Cmdlets: These are special .NET classes that perform actions. They have a verb-noun naming convention, like
Get-Process
orSet-Service
. - Objects: Unlike traditional shells that deal with text, PowerShell passes objects between cmdlets. This makes it more powerful and easier to work with structured data.
- Pipelines: You can chain cmdlets together using the pipe symbol (
|
) to send the output objects from one cmdlet as input to another.
Installing PowerShell
PowerShell comes pre-installed with modern versions of Windows. However, you might want to install the latest version or PowerShell Core (which runs on Windows, macOS, and Linux).
For Windows 10 and later:
Open PowerShell (search for it in the Start menu) and run the following command to check your version:
$PSVersionTable.PSVersion
If you need to update, you can often do so through the Microsoft Store. Search for "PowerShell".
Installing PowerShell Core (Cross-Platform):
For the latest features and cross-platform support, install PowerShell 7.x:
- Visit the PowerShell releases page on GitHub.
- Download the appropriate installer for your operating system (Windows, macOS, or Linux).
- Follow the installation instructions for your platform.
After installation, you can launch PowerShell Core by typing pwsh
in your terminal or command prompt.
Your First Commands
Let's run some basic commands to get familiar:
- Get the current directory:
Get-Location
- List files and folders in the current directory:
Get-ChildItem
You can also use the alias
ls
ordir
for this. - Get information about a process:
Get-Process notepad
- Display system information:
Get-ComputerInfo
Using Help
PowerShell has extensive built-in help. To get help on any cmdlet, use Get-Help
:
Get-Help Get-Process
Get-Help Get-Process -Examples
Get-Help Get-Process -Full
Next Steps
Now that you've got the basics, consider exploring:
Happy scripting!