Blog about Web Programming and Electronics
💬 👤
back Back to blog
Windows

Most Useful PowerShell Commands for Managing Windows Systems

Windows PowerShell is an extremely powerful tool for automation and managing the Windows operating system. Unlike the traditional Command Prompt (CMD), which handles plain text, PowerShell is built on top of the .NET framework and works natively with objects. In this article, we will cover key cmdlets that will save you time in daily system and network administration.

Basic PowerShell Command Structure

Commands in PowerShell follow a standardized Verb-Noun syntax, making them consistent and easy to learn.

Cmdlet Function Usage Description
Get-Process Process Management Lists all currently running processes on the system.
Get-Service Service Management Displays the status of system services (running/stopped).
Test-NetConnection Network Diagnostics Checks network connectivity and tests specific port availability.

File and System Information Management

By using the pipeline operator (`|`), the output of one command can be passed directly as input to another, allowing for powerful data filtering.

  1. Get-ChildItem: Displays files and directories (equivalent to `dir` or `ls`).
  2. Get-Content: Reads and prints the contents of a file into the terminal.
  3. Select-Object: Selects specific properties of an object (e.g., process name and RAM usage).
  4. Where-Object: Filters results based on specified conditions.

Practical PowerShell Usage Examples

The example below demonstrates practical PowerShell commands for identifying high-resource processes and testing network ports.

# 1. Retrieve top 5 processes consuming the most RAM
Get-Process | Sort-Object WorkingSet64 -Descending | Select-Object -First 5 Name, WorkingSet64

# 2. Check if a server is reachable on port 80 (HTTP)
Test-NetConnection -ComputerName "example.com" -Port 80

# 3. Stop a specific system service (requires Administrator rights)
Stop-Service -Name "Spooler"

The Power of the PowerShell Pipeline

The primary advantage of PowerShell over other shells is that objects—not just text strings—flow through the pipeline with all their properties and methods intact. This enables precise filtering and easy exporting of results to formats like CSV or JSON (e.g., using Export-Csv or ConvertTo-Json).

back Back to blog