Lesson 07 — Windows PowerShell Fundamentals
Lesson 07 — Windows PowerShell Fundamentals
Section titled “Lesson 07 — Windows PowerShell Fundamentals”Lesson Overview
Section titled “Lesson Overview”Imagine you’re responsible for managing:
- 2,000 Windows laptops
- 500 Windows Servers
- Multiple Azure Virtual Machines
- Active Directory users
- Microsoft 365 services
Would you manually configure each system using the graphical interface?
Absolutely not.
Enterprise administrators automate repetitive tasks using Windows PowerShell.
PowerShell is Microsoft’s powerful command-line shell and scripting language designed specifically for system administration and automation.
Whether you’re creating users, restarting services, collecting logs, deploying software, or managing Azure resources, PowerShell helps you perform tasks faster, more consistently, and at enterprise scale.
Learning Objectives
Section titled “Learning Objectives”After completing this lesson, you will be able to:
- Understand Windows PowerShell.
- Learn PowerShell architecture.
- Execute PowerShell commands.
- Understand cmdlets and objects.
- Work with variables and pipelines.
- Create simple PowerShell scripts.
- Apply PowerShell automation in enterprise environments.
What is PowerShell?
Section titled “What is PowerShell?”PowerShell is Microsoft’s command-line shell, scripting language, and automation framework.
It is built on the .NET platform and is designed to automate system administration tasks.
PowerShell can manage:
- Windows
- Active Directory
- Microsoft Azure
- Microsoft 365
- Hyper-V
- SQL Server
- Exchange Server
- Windows Services
- File Systems
- Registry
Why PowerShell Matters
Section titled “Why PowerShell Matters”PowerShell helps administrators:
- Automate repetitive tasks
- Reduce manual errors
- Manage thousands of systems
- Perform remote administration
- Build deployment scripts
- Generate reports
- Configure enterprise infrastructure
PowerShell is one of the most valuable skills for Windows Administrators and Cloud Engineers.
PowerShell vs Command Prompt
Section titled “PowerShell vs Command Prompt”| Command Prompt | PowerShell |
|---|---|
| Text-based output | Object-based output |
| Limited scripting | Advanced scripting |
| Basic administration | Enterprise automation |
| Older Windows tool | Modern administration platform |
PowerShell is the preferred management tool in modern Windows environments.
Opening PowerShell
Section titled “Opening PowerShell”Open PowerShell by:
- Start Menu → Windows PowerShell
- Windows Terminal
- Search for PowerShell
Or press:
Win + X
↓
Windows PowerShellFor administrative tasks, launch PowerShell as Administrator.
Understanding Cmdlets
Section titled “Understanding Cmdlets”PowerShell commands are called Cmdlets.
They follow a standard naming convention:
Verb-NounExamples:
Get-Service
Get-Process
Get-ChildItem
Start-Service
Stop-Service
Restart-ServiceThis naming convention makes commands easier to discover and remember.
Getting Help
Section titled “Getting Help”Display help for a cmdlet.
Get-Help Get-ServiceUpdate help files.
Update-HelpDisplay examples.
Get-Help Get-Service -ExamplesLearning to use the built-in help system is an essential PowerShell skill.
Discovering Commands
Section titled “Discovering Commands”List available cmdlets.
Get-CommandSearch for service-related commands.
Get-Command *service*Search for process commands.
Get-Command *process*PowerShell Objects
Section titled “PowerShell Objects”Unlike traditional command-line tools, PowerShell works with Objects instead of plain text.
Example:
Get-ServiceReturns service objects containing properties such as:
- Name
- Status
- DisplayName
- StartupType
Objects make automation far more powerful than text parsing.
Viewing Object Properties
Section titled “Viewing Object Properties”Inspect object details.
Get-Service | Get-MemberDisplay selected properties.
Get-Service | Select-Object Name, StatusVariables
Section titled “Variables”Variables store information.
Example:
$name = "GoHackersCloud"
Write-Host $nameOutput:
GoHackersCloudVariables simplify scripting and automation.
Built-in Variables
Section titled “Built-in Variables”PowerShell includes predefined variables.
Examples:
$HOME
$PROFILE
$PSVersionTableDisplay PowerShell version.
$PSVersionTableWorking with the Pipeline
Section titled “Working with the Pipeline”The pipeline (|) passes objects from one command to another.
Example:
Get-Service | Sort-Object StatusAnother example:
Get-Process | Select-Object Name, CPUPipelines are one of PowerShell’s most powerful features.
Filtering Results
Section titled “Filtering Results”Display only running services.
Get-Service | Where-Object {$_.Status -eq "Running"}Filter processes using more complex conditions as needed.
Sorting Results
Section titled “Sorting Results”Sort processes by CPU usage.
Get-Process | Sort-Object CPU -DescendingWorking with Files
Section titled “Working with Files”Display files.
Get-ChildItemEquivalent to:
dirChange directory.
Set-Location C:\UsersDisplay current directory.
Get-LocationManaging Processes
Section titled “Managing Processes”Display processes.
Get-ProcessStop a process.
Stop-Process -Name notepadManaging Services
Section titled “Managing Services”Display services.
Get-ServiceRestart a service.
Restart-Service SpoolerManaging Event Logs
Section titled “Managing Event Logs”Display recent system events.
Get-EventLog -LogName System -Newest 20For newer Windows versions, administrators often use:
Get-WinEventCreating Your First Script
Section titled “Creating Your First Script”Create a file.
hello.ps1Example:
Write-Host "Welcome to GoHackersCloud Academy!"Run:
.\hello.ps1Execution Policy
Section titled “Execution Policy”Windows controls script execution using an execution policy.
View the current policy.
Get-ExecutionPolicyCommon values include:
- Restricted
- RemoteSigned
- AllSigned
- Unrestricted
Organizations should choose an execution policy that aligns with their security requirements.
Remote Administration
Section titled “Remote Administration”PowerShell supports remote management.
Example:
Enter-PSSession Server01Or:
Invoke-CommandRemote administration allows administrators to manage servers without logging in interactively.
PowerShell in Active Directory
Section titled “PowerShell in Active Directory”Examples include:
Create users:
New-ADUserDisplay users:
Get-ADUserDisplay groups:
Get-ADGroupThese cmdlets require the Active Directory PowerShell module.
PowerShell in Azure
Section titled “PowerShell in Azure”Cloud Engineers use PowerShell to:
- Create Virtual Machines
- Manage Storage Accounts
- Configure Virtual Networks
- Deploy Resources
- Manage Microsoft Entra ID
PowerShell is widely used alongside Azure CLI and infrastructure-as-code tools.
PowerShell in Cybersecurity
Section titled “PowerShell in Cybersecurity”Security professionals use PowerShell for:
- Log Analysis
- User Auditing
- Incident Response
- Malware Investigation
- Security Automation
- Threat Hunting
PowerShell is also frequently targeted by attackers, making logging and monitoring especially important.
Common PowerShell Commands
Section titled “Common PowerShell Commands”Display help:
Get-HelpList commands:
Get-CommandDisplay processes:
Get-ProcessDisplay services:
Get-ServiceDisplay files:
Get-ChildItemDisplay current directory:
Get-LocationDisplay computer information:
Get-ComputerInfoReal-World Example
Section titled “Real-World Example”An administrator needs to check the status of the Print Spooler service on 100 Windows servers.
Instead of manually logging into each server:
PowerShell Script
↓
Connect to Servers
↓
Check Service Status
↓
Generate Report
↓
Email Results
↓
Complete in MinutesAutomation significantly reduces administrative effort and improves consistency.
Best Practices
Section titled “Best Practices”As a Windows administrator:
- Learn the Verb-Noun cmdlet naming convention.
- Use
Get-Helpbefore running unfamiliar commands. - Test scripts in a lab before production.
- Use meaningful variable names.
- Store scripts in version control systems like Git.
- Apply the Principle of Least Privilege.
- Digitally sign scripts where required.
- Enable PowerShell logging and auditing in enterprise environments.
Automation should improve efficiency without compromising security.
Key Takeaways
Section titled “Key Takeaways”After completing this lesson, you should understand:
- PowerShell fundamentals.
- Cmdlets.
- Objects.
- Variables.
- Pipelines.
- Basic scripting.
- Remote administration.
- Enterprise PowerShell automation.
Summary
Section titled “Summary”PowerShell is the primary automation and administration platform for modern Windows environments.
Its object-based architecture, extensive cmdlet library, and scripting capabilities enable administrators to automate repetitive tasks, manage enterprise infrastructure, and integrate with cloud platforms.
Mastering PowerShell is an essential step toward becoming an effective Windows Administrator, Cloud Engineer, DevOps Engineer, or Cybersecurity Professional.
Next Lesson
Section titled “Next Lesson”➡️ Lesson 08 — Windows Networking
In the next lesson, you’ll learn how Windows communicates over networks, understand IP addressing, DNS, DHCP, routing, Windows Firewall, network troubleshooting, and enterprise networking concepts used in corporate environments.