PowerShell Basics for Windows Server Administration

PowerShell is the primary command-line and scripting tool for managing Windows Server — equivalent to what bash/SSH is for Linux administration. This guide covers the essential commands every Windows VPS admin should know.

Opening PowerShell as Administrator

Right-click the Start button → Windows PowerShell (Admin), or search "PowerShell," right-click, and select Run as Administrator. Most administrative commands require elevated privileges.

Checking System Information

Get-ComputerInfo | Select WindowsProductName, OsVersion, CsProcessors

Checking Disk Space

Get-PSDrive -PSProvider FileSystem

Checking Memory and CPU Usage

Get-Counter '\Processor(_Total)\% Processor Time'
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10

Managing Services

Get-Service
Get-Service -Name "Spooler"
Start-Service -Name "Spooler"
Stop-Service -Name "Spooler"
Restart-Service -Name "Spooler"

Managing Processes

Get-Process
Stop-Process -Name "notepad" -Force

Managing Firewall Rules

Get-NetFirewallRule | Select DisplayName, Enabled, Direction, Action
New-NetFirewallRule -DisplayName "Allow Port 8080" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow

Managing Users

Get-LocalUser
New-LocalUser "deploy" -Password (Read-Host -AsSecureString "Password")
Add-LocalGroupMember -Group "Administrators" -Member "deploy"

Managing Windows Features/Roles

Get-WindowsFeature
Install-WindowsFeature -Name Web-Server -IncludeManagementTools
Uninstall-WindowsFeature -Name Web-Server

Networking Commands

Get-NetIPAddress
Test-NetConnection -ComputerName google.com -Port 443
Get-NetTCPConnection | Where-Object {$_.State -eq "Listen"}

Viewing Event Logs

Get-EventLog -LogName System -Newest 20
Get-EventLog -LogName Security -Newest 20 | Where-Object {$_.EntryType -eq "FailureAudit"}

Scheduling Tasks (Windows Equivalent of Cron)

$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File C:\Scripts\backup.ps1"
$trigger = New-ScheduledTaskTrigger -Daily -At 2am
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "Daily Backup" -RunLevel Highest

Restarting the Server

Restart-Computer -Force

Running a Script

powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\myscript.ps1

Windows restricts script execution by default; -ExecutionPolicy Bypass allows running an unsigned script for this session only, without permanently changing system-wide policy.

Getting Help for Any Command

Get-Help Get-Service -Full

Common Errors

"Running scripts is disabled on this system" — the execution policy is blocking script execution:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

"Access is denied" — PowerShell isn't running as Administrator; close it and reopen with "Run as Administrator."

Best Practices

  • Always run administrative PowerShell as Administrator, but avoid staying elevated for non-administrative daily tasks
  • Test scripts on a non-production server before running against production
  • Use Get-Help liberally — it's built-in and always accurate for your installed version

Related Articles

  • How to Configure Windows Firewall on a Windows VPS
  • How to Create a New Administrator User on Windows Server
  • How to Install Windows Updates on a Windows VPS
  • powershell, windows server administration, windows commands
  • 0 Bu dökümanı faydalı bulan kullanıcılar:
Bu cevap yeterince yardımcı oldu mu?

İlgili diğer dökümanlar

How to Connect to a Windows VPS via Remote Desktop (RDP)

Remote Desktop Protocol (RDP) provides full graphical access to a Windows Server VPS, letting you...

How to Secure RDP on a Windows VPS

RDP's default configuration (standard port, password authentication, unlimited login attempts)...

How to Create a New Administrator User on Windows Server

Using only the built-in Administrator account for all management tasks is risky. Creating a...

How to Install Windows Updates on a Windows VPS

Keeping Windows Server updated is essential for security and stability. This guide covers...

How to Configure Windows Firewall on a Windows VPS

Windows Defender Firewall controls which network connections are allowed to and from your server....