Windows & Linux · PowerShell Fundamentals

PowerShell Fundamentals

A practical walkthrough of PowerShell’s object-based shell and scripting language—cmdlets, syntax, objects, scripting basics, policies, debugging, and real-world tasks.

View this project on GitHub

Introduction: What is PowerShell?

PowerShell is a powerful command-line shell and scripting language built on .NET (and .NET Core for cross-platform PowerShell). Designed for admins and power users, it automates tasks, manages configurations, and interacts with APIs, the registry, and the file system. Unlike traditional text-based shells, PowerShell is object-based—commands pass rich objects, not just text—unlocking precise filtering, formatting, and automation.

Getting Started with PowerShell

.NET and .NET Core Foundations

.NET Framework

The .NET Framework provides PowerShell with the CLR runtime and vast class libraries. When you run Get-Process, format with Select-Object, or manage services, you’re leveraging .NET types and methods under the hood—enabling rich, object-first automation.

.NET Core

.NET Core (now .NET 6/7/8+) powers cross-platform PowerShell (a.k.a. PowerShell Core). It’s modular, fast, and open source—ideal for modern automation across Windows, Linux, and macOS.

Windows PowerShell and PowerShell (Core)

Windows PowerShell

PowerShell (Core)

Cmdlets & Basic Syntax and Structure

Cmdlets are small, purpose-built commands that follow a clear Verb-Noun pattern and output objects. They’re the building blocks of PowerShell automation.

Naming Format

VerbNounMeaning
Get-HelpDisplays help for cmdlets
Get-CommandLists available commands
Get-ProcessShow running processes
Get-ServiceShow services
Start-ServiceStart a service
Restart-ServiceRestart a service
Stop-ServiceStop a service
Get-Help screenshot
Get-Command screenshot
Get-Process screenshot
Get-Service screenshot
Service management examples

Exploration

$PSVersionTable
Get-Module -ListAvailable
Get-Command -Module ModuleName
Get-FileHash
Get-FileHash -Algorithm SHA1 -Path
Get-NetAdapter
Select-Object
Get-NetAdapter | Select-Object Name, Status, LinkSpeed
Set-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Enabled True
Get-NetFirewallRule -DisplayGroup "Network Discovery"
(Get-WmiObject -Query 'select * from SoftwareLicensingService').OA3xOriginalProductKey
wmic bios get serialnumber
New-NetFirewallRule -DisplayName "Block Specific IP" -Direction Inbound -Action Block -RemoteAddress "192.168.1.100" -Protocol Any
New-NetFirewallRule -DisplayName "Block Specific IP Outbound" -Direction Outbound -Action Block -RemoteAddress "192.168.1.100" -Protocol Any
Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion
net users
net groups
net user administrator
Get-LocalGroupMember -Group "Administrators"
Remove-LocalGroupMember -Group "Administrators" -Member "Domain Users"

Get-Module -ListAvailable

Get-Module list
More module listings

Command discovery across modules

WindowsUpdate commands
NetAdapter commands
NetTCPIP commands
TroubleshootingPack commands
NetworkConnectivityStatus commands
NetSecurity commands list

Networking & hash basics

NetSecurity module
Get-FileHash output
Get-NetAdapter output
Adapter selected properties

Firewall rules & discovery

Enable File and Printer Sharing rule
Network Discovery rules

Retrieve computer serial number

Serial number retrieval

Block IP inbound/outbound

New-NetFirewallRule -DisplayName "Block Specific IP" -Direction Inbound -Action Block -RemoteAddress "192.168.1.100" -Protocol Any
Inbound block rule
New-NetFirewallRule -DisplayName "Block Specific IP Outbound" -Direction Outbound -Action Block -RemoteAddress "192.168.1.100" -Protocol Any
Outbound block rule

Get-ComputerInfo & selected properties

ComputerInfo full
Selected OS properties 1
Selected OS properties 2

Local users & groups

net user
net group
net user administrator

Modern local group cmdlets

Get-LocalGroupMember
Modify local group members

Working with Files and Directories

Get-ChildItem
New-Item
Remove-Item
echo
mkdir
Move-Item
Copy-Item
ls

The familiar Linux-style commands like mkdir, echo, and ls also work in a PowerShell session.

PowerShell Scripting Basics

Core building blocks that underpin automation and administration with PowerShell.

Data Types (Variables, Strings, Integers)

Arrays

Booleans

Loops and Conditional Statements

Objects

Functions

function Greet-User {
  param ($Name)
  "Welcome, $Name!"
}
Greet-User -Name "Dave"

Scripts end with the .ps1 extension.

Permissions and Execution Policy

Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned

Policies: Restricted · AllSigned · RemoteSigned · Unrestricted

Administrator privileges may be required.

Useful Tools and Debugging

Write-Host vs Write-Output

Start-Transcript

try / catch / finally

Real-World Use Cases

Batch user creation in AD

1. Create a CSV with user attributes (example in Notepad++):

Automating updates

Backing up and archiving logs

Scheduled tasks and reporting

PowerShell gives IT pros control and automation that save time, reduce errors, and improve reliability. Mastering the fundamentals is step one toward serious automation chops.

Back to Home