PowerShell lets you manage a Windows Server faster than clicking through menus, and the same commands work in scripts and scheduled tasks. This guide covers the commands you will use most on a VPS, grouped by task.
Before you start
- An RDP session as an administrator (see connect with RDP).
- Open PowerShell as administrator: right-click Start → Windows PowerShell (Admin) or Terminal (Admin).
Find commands and help
Get-Command *service*
Get-Help Get-Service -Examples
Get-Service | Get-MemberCommands follow a Verb-Noun pattern (Get-, Set-, Start-, Stop-). Press Tab to complete names.
Services
Get-Service | Where-Object Status -eq 'Running'
Restart-Service W3SVC
Set-Service -Name W3SVC -StartupType AutomaticProcesses
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10
Get-Process | Sort-Object WorkingSet -Descending | Select-Object -First 10 Name, @{n="MB";e={[int]($_.WorkingSet/1MB)}}
Stop-Process -Name notepadFiles and folders
Get-ChildItem C:\inetpub -Recurse -Filter *.config
Copy-Item C:\site C:\backup\site -Recurse
Compress-Archive -Path C:\site -DestinationPath C:\backup\site.zip
Get-Content C:\logs\app.log -Tail 50 -WaitDisk space
Get-Volume
Get-PSDrive -PSProvider FileSystemNetwork
Get-NetIPAddress -AddressFamily IPv4
Test-NetConnection example.com -Port 443
Get-NetTCPConnection -State Listen | Sort-Object LocalPortFirewall rules have their own guide: RDP firewall rule.
Local users
Get-LocalUser
New-LocalUser -Name "alex" -Password (Read-Host -AsSecureString)
Add-LocalGroupMember -Group "Remote Desktop Users" -Member "alex"See create a Windows user with RDP access.
System info, events and restarts
Get-ComputerInfo | Select-Object WindowsProductName, OsVersion, CsTotalPhysicalMemory
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 5
Get-WinEvent -LogName System -MaxEvents 20
Restart-ComputerExecution policy for scripts
To run your own .ps1 scripts, RemoteSigned is a sensible default:
Set-ExecutionPolicy RemoteSigned -Scope LocalMachineWarning: Never paste scripts from untrusted sites into an admin PowerShell window. Read what a script does first. For a locked-down approach see PowerShell execution policies.
