
A practical walkthrough of PowerShell’s object-based shell and scripting language—cmdlets, syntax, objects, scripting basics, policies, debugging, and real-world tasks.
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.
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 (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.
Cmdlets are small, purpose-built commands that follow a clear Verb-Noun pattern and output objects. They’re the building blocks of PowerShell automation.
Verb | Noun | Meaning |
---|---|---|
Get- | Help | Displays help for cmdlets |
Get- | Command | Lists available commands |
Get- | Process | Show running processes |
Get- | Service | Show services |
Start- | Service | Start a service |
Restart- | Service | Restart a service |
Stop- | Service | Stop a service |
$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
Command discovery across modules
Networking & hash basics
Firewall rules & discovery
Retrieve computer serial number
Block IP inbound/outbound
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 & selected properties
Local users & groups
Modern local group cmdlets
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.
Core building blocks that underpin automation and administration with PowerShell.
function Greet-User {
param ($Name)
"Welcome, $Name!"
}
Greet-User -Name "Dave"
Scripts end with the .ps1
extension.
Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned
Policies: Restricted · AllSigned · RemoteSigned · Unrestricted
Administrator privileges may be required.
Write-Host
vs Write-Output
Start-Transcript
to log sessionstry/catch/finally
for error handling1. Create a CSV with user attributes (example in Notepad++):
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.