MSDN Resources: PowerShell Basics

Your essential guide to getting started with Windows PowerShell.

Introduction to PowerShell

Windows PowerShell is a 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. PowerShell allows administrators to automate repetitive tasks, manage systems efficiently, and deploy applications.

Key Concepts:

Your First PowerShell Commands

Let's explore some fundamental commands to get you comfortable.

Getting Help

The Get-Help cmdlet is your best friend when learning PowerShell. Use it to find information about cmdlets, concepts, and more.

Get-Help Get-Process -Full

This command provides detailed help for the Get-Process cmdlet, showing its parameters and examples.

Navigating the File System

Similar to the Command Prompt, you can navigate directories.

Set-Location C:\Users\Public Get-Location Get-ChildItem

Set-Location changes the current directory. Get-Location shows your current directory. Get-ChildItem lists the contents of the current directory.

Managing Processes

View and manage running processes on your system.

Get-Process Get-Process -Name "explorer" Stop-Process -Name "notepad" -Force

Get-Process lists all running processes. You can filter by name. Stop-Process terminates a specified process.

Working with Services

Control and view Windows services.

Get-Service Get-Service -Name "wuauserv" Start-Service -Name "spooler" Stop-Service -Name "spooler"

Get-Service lists services. You can start, stop, and restart services using their respective cmdlets.

Basic Scripting Concepts

PowerShell's true power lies in its scripting capabilities. Here are some foundational elements.

Variables

Use variables to store data.

$userName = "AdminUser"
Write-Host "Hello, $($userName)!"

Conditional Statements

Control the flow of your scripts.

$fileSize = 1024
if ($fileSize -gt 500) {
    Write-Host "File is large."
} else {
    Write-Host "File is small."
}

Loops

Execute commands repeatedly.

for ($i = 1; $i -le 5; $i++) {
    Write-Host "Iteration number: $i"
}

Next Steps

This is just the beginning. To further enhance your PowerShell skills: