Situatie
PowerShell is much more than a replacement for Command Prompt. It combines a command-line shell with a scripting language and an object-based pipeline, making it one of the most useful administration tools available on Windows.
Navigation and Files
Get-Location
Displays your current location.
Get-ChildItem
Lists files and directories.
Set-Location C:\Temp
Changes the current directory.
New-Item -ItemType Directory -Path C:\Temp\Test
Creates a directory.
Copy-Item
Copies files or directories.
Move-Item
Moves files.
Remove-Item
Deletes items. Use this carefully.
Processes
Get-Process
Displays running processes.
Stop-Process
Terminates a process.
Example:
Stop-Process -Name notepad
Services
Get-Service
Lists Windows services.
Start-Service
Starts a service.
Stop-Service
Stops a service.
Restart-Service
Restarts a service.
Example:
Restart-Service Spooler
Networking
Get-NetIPAddress
Displays IP configuration.
Get-NetAdapter
Lists network adapters.
Test-NetConnection google.com
Tests network connectivity and provides more diagnostic information than a simple ping in many scenarios.
Example:
Test-NetConnection server01 -Port 443
can test whether a specific TCP port is reachable.
System Information
Get-ComputerInfo
Retrieves extensive Windows and hardware information.
Get-CimInstance Win32_OperatingSystem
Retrieves operating-system information through CIM.
Getting Help
Get-Help
This is arguably one of the most important PowerShell commands.
For example:
Get-Help Get-Service -Examples
shows examples for the Get-Service cmdlet.
Discovering Commands
Get-Command
If you know roughly what you want to do but don’t know the exact cmdlet, Get-Command can help.
For example:
Get-Command *service*
The Pipeline
The real power of PowerShell becomes apparent when commands are combined.
For example:
Get-Service | Where-Object Status -eq "Running"
retrieves services and filters the objects to show running services. Unlike traditional shells that primarily pass text between commands, PowerShell passes structured objects.That difference is fundamental.
Leave A Comment?