1 Introduction to PowerShell
PowerShell is a command‑line shell and scripting language created by Microsoft that helps you automate tasks, manage systems, and work with data more
efficiently. It comes preinstalled on modern Windows systems.
Command-line shell: Like Command Prompt, but much more powerful.
Scripting language: Lets you write .ps1 scripts to automate repetitive tasks.
Object-oriented: Unlike Command Prompt, which outputs plain text, PowerShell works with .NET objects, making data easier to filter and manipulate.
2 🔑 Utility
Automate tasks: Copy files, back up folders, or schedule cleanups.
Configuration management: Change system settings or manage user accounts.
Server and cloud management: Widely used in IT and DevOps.
Custom tools: You can build your own utilities with scripts.
3 📝 Basic Concepts
Cmdlets: Small built‑in commands like Get-ChildItem (list files) or Copy-Item (copy files).
Pipelines: You can chain commands together using | to pass data from one command to another.
Variables: Store values with $ , e.g., $name = "Alice" .
Scripts: Save commands in a .ps1 file and run them to automate tasks.
Try a simple command:
Get-Process
3.1 Basic Commands (Cmdlets)
Cmdlets follow the format: Verb-Noun
Examples:
Get-Command → lists all available commands
Get-Help Get-Date → shows help for a command
Get-Date → displays current date and time
Detailed help:
Get-Help Get-Process -Detailed
➡ Includes parameters and usage notes.
Examples:
Get-Help Get-Process -Examples
➡ Shows ready-to-use examples (super useful for beginners).
Full help:
Get-Help Get-Process -Full
➡ Displays everything: syntax, parameters, examples, and notes.
If help content looks short, run:
Update-Help
➡ Downloads the latest help files from Microsoft.
3.2 Working with Files & Folders
Get-Location → show current folder
Set-Location C:\ → change folder
Get-ChildItem → list files/folders
New-Item [Link] → create a file
New-Item test -ItemType Directory → create a folder
Common Aliases:
ls → Get-ChildItem
cd → Set-Location
pwd → Get-Location
💡 Tip: Aliases are shortcuts—great for beginners, but learn the full cmdlets for clarity.
3.3 Variables
$name = "Alice"
$age = 25
Write-Output "My name is $name and I am $age years old"
💡 Tip: Variables always start with $ . They can store text, numbers, or even entire objects.
3.4 Pipelines (PowerShell’s Superpower )
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5
➡ Shows the top 5 processes using the most CPU.
💡 Tip: The | symbol (pipe) connects commands—think of it as “send this result to the next step.”
3.5 Writing a Simple Script
Create a file hello.ps1:
Write-Output "Hello, PowerShell!"
Get-Date
Run it:
.\hello.ps1
⚠️If scripts are blocked:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Or
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Best Luck <3