---
title: "Cấu hình PowerShell tự động kiểm tra port đang mở và tiến trình chiếm băng thông trên Windows Server VPS"
description: "Hướng dẫn dùng PowerShell tự động quét các port TCP/UDP đang mở và phát hiện tiến trình chiếm dụng băng thông bất thường trên Windows Server VPS."
canonical: "https://thuecloud.vn/cau-hinh-powershell-tu-dong-kiem-tra-port-dang-mo-va-tien-trinh-chiem-bang-thong-tren-windows-server-vps"
markdown_url: "https://thuecloud.vn/cau-hinh-powershell-tu-dong-kiem-tra-port-dang-mo-va-tien-trinh-chiem-bang-thong-tren-windows-server-vps.md"
locale: "vi"
kind: "article"
published_at: "2026-11-22T16:18:24.667Z"
updated_at: "2026-11-22T16:18:22.184Z"
site: "ThueCloud.Vn"
estimated_tokens: 1956
---
# Cấu hình PowerShell tự động kiểm tra port đang mở và tiến trình chiếm băng thông trên Windows Server VPS

> Hướng dẫn dùng PowerShell tự động quét các port TCP/UDP đang mở và phát hiện tiến trình chiếm dụng băng thông bất thường trên Windows Server VPS.

- Canonical HTML: https://thuecloud.vn/cau-hinh-powershell-tu-dong-kiem-tra-port-dang-mo-va-tien-trinh-chiem-bang-thong-tren-windows-server-vps
- Markdown URL: https://thuecloud.vn/cau-hinh-powershell-tu-dong-kiem-tra-port-dang-mo-va-tien-trinh-chiem-bang-thong-tren-windows-server-vps.md
- Organization: ThueCloud.Vn
- Support Email: support@thuecloud.vn
- Hotline: 03333 499 48
- Published: 2026-11-22
- Updated: 2026-11-22

## Mục lục

- Các Cmdlet PowerShell quan trọng để kiểm tra mạng
- Script PowerShell kiểm tra Port và Băng thông tự động
  - Liệt kê toàn bộ Port đang mở kèm tên tiến trình và đường dẫn
  - Script giám sát Port lạ và đo tốc độ băng thông card mạng
- Câu hỏi thường gặp (FAQ)
  - Tại sao thấy nhiều port động (từ 49152 trở lên) đang ở trạng thái Listen?
  - Làm sao chặn nhanh một tiến trình chiếm băng thông bất thường mà không cần gỡ phần mềm?
  - Có thể gửi cảnh báo từ script PowerShell này về Telegram không?

Khi nhận thấy [Windows Server VPS](https://thuecloud.vn/vps-viet-nam) phản hồi chậm hoặc lưu lượng mạng tăng đột biến, việc mở Resource Monitor thủ công không giúp bạn ghi lại lịch sử hay phát hiện nhanh các tiến trình chạy ngầm bất thường. Sử dụng **PowerShell** để tự động hóa kiểm tra port đang lắng nghe (`Listen`) và đo lưu lượng từng tiến trình giúp bạn phát hiện sớm lỗ hổng bảo mật hoặc tool ngốn băng thông.

> **Tóm tắt nhanh (TL;DR):**
> - Dùng `Get-NetTCPConnection -State Listen` kết hợp `Get-Process` để lập bản đồ chính xác port nào thuộc về file `.exe` nào.
> - Dùng `Get-Counter` hoặc `Get-NetAdapterStatistics` để theo dõi tốc độ gửi/nhận theo thời gian thực.
> - Lập lịch script xuất cảnh báo khi phát hiện port lạ ngoài danh sách cho phép (whitelist).
> - *Cập nhật: 11/2026*

## Các Cmdlet PowerShell quan trọng để kiểm tra mạng

| Cmdlet PowerShell | Thông tin trả về | Ứng dụng thực tế |
| :--- | :--- | :--- |
| `Get-NetTCPConnection` | Danh sách port, IP đích, trạng thái và `OwningProcess` | Phát hiện backdoor hoặc dịch vụ mở nhầm ra `0.0.0.0` |
| `Get-NetUDPEndpoint` | Các port UDP đang lắng nghe | Kiểm tra DNS, VPN hoặc dịch vụ game/media |
| `Get-NetAdapterStatistics` | Tổng byte gửi/nhận trên card mạng | Đo lưu lượng tổng thể nhanh gọn |

Nếu bạn đang vận hành hệ thống AI hoặc crawler trên hạ tầng kết hợp, xem thêm [triển khai n8n + Gemini 4 trên Cloud VPS](https://thuecloud.vn/trien-khai-ai-automation-nganh-cham-soc-khach-hang-saas-bang-n8n-gemini-4-tren-cloud-vps) hoặc [cài đặt Crawlee Node.js Scraper](https://thuecloud.vn/crawllee-node-js-scraper-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te).

## Script PowerShell kiểm tra Port và Băng thông tự động

### 1. Liệt kê toàn bộ Port đang mở kèm tên tiến trình và đường dẫn

Chạy đoạn lệnh sau trong PowerShell (Administrator) để xem ngay dịch vụ nào đang mở cổng ra mạng:

```powershell
Get-NetTCPConnection -State Listen | Select-Object LocalAddress, LocalPort, OwningProcess, @{
    Name='ProcessName'; Expression={(Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName}
}, @{
    Name='Path'; Expression={(Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).Path}
} | Sort-Object LocalPort | Format-Table -AutoSize
```

### 2. Script giám sát Port lạ và đo tốc độ băng thông card mạng

Lưu script sau thành `C:\Scripts\Monitor-NetworkHealth.ps1`:

```powershell
$AllowedPorts = @(80, 443, 3389, 135, 445)
$OpenPorts = Get-NetTCPConnection -State Listen | Where-Object { $_.LocalAddress -eq '0.0.0.0' -or $_.LocalAddress -eq '::' }

foreach ($conn in $OpenPorts) {
    if ($AllowedPorts -notcontains $conn.LocalPort) {
        $proc = Get-Process -Id $conn.OwningProcess -ErrorAction SilentlyContinue
        Write-Warning "[PORT ALERT] Port $($conn.LocalPort) đang mở bởi $($proc.ProcessName) (PID: $($conn.OwningProcess))"
    }
}

# Đo tốc độ băng thông nhận/gửi trong 3 giây
$counter = Get-Counter '\Network Interface(*)\Bytes Total/sec' -SampleInterval 3 -MaxSamples 1
$counter.CounterSamples | Where-Object { $_.CookedValue -gt 1024 } | Select-Object InstanceName, @{
    Name='MBps'; Expression={[math]::Round($_.CookedValue / 1MB, 2)}
} | Format-Table -AutoSize
```

> **Hạ tầng Windows VPS ổn định, băng thông cao tại ThueCloud.Vn:**
> Trải nghiệm **KVM Enterprise NVMe tại vn-hn** với **VAT 0%**, **SLA 99,9%**, **hoàn tiền 07 ngày**.
> - Gói **VPS VN 2** (`78.000đ`–`90.000đ/tháng`) và **VPS VN 3** (`139.000đ`–`170.000đ/tháng`) đáp ứng tốt mọi tác vụ Windows Server & giám sát mạng.
> - Xem chi tiết tại [bảng giá](https://thuecloud.vn/pricing) và [FAQ ThueCloud](https://thuecloud.vn/faq).

## Câu hỏi thường gặp (FAQ)

### Tại sao thấy nhiều port động (từ 49152 trở lên) đang ở trạng thái Listen?
Đó là các cổng RPC động của hệ điều hành Windows (như `svchost.exe`, `lsass.exe`, `services.exe`). Bạn có thể kiểm tra đường dẫn `Path` của tiến trình để xác nhận nó nằm trong `C:\Windows\System32\`.

### Làm sao chặn nhanh một tiến trình chiếm băng thông bất thường mà không cần gỡ phần mềm?
Bạn có thể tạo rule chặn outbound trong Windows Firewall ngay bằng PowerShell: `New-NetFirewallRule -DisplayName "Block App" -Direction Outbound -Program "C:\path\to\app.exe" -Action Block`.

### Có thể gửi cảnh báo từ script PowerShell này về Telegram không?
Có. Bạn chỉ cần dùng `Invoke-RestMethod -Uri "https://api.telegram.org/bot<TOKEN>/sendMessage" -Method Post -Body @{chat_id=$ChatId; text=$Message}` ngay bên trong vòng lặp `foreach` khi phát hiện port lạ.

## References / Sources

- https://learn.microsoft.com/en-us/powershell/module/nettcpip/get-nettcpconnection
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.diagnostics/get-counter

---

## Navigation & Machine-Readable Endpoints

- [Site Summary (llms.txt)](https://thuecloud.vn/llms.txt)
- [Full Technical Reference (llms-full.txt)](https://thuecloud.vn/llms-full.txt)
- [Pricing Catalog (Markdown)](https://thuecloud.vn/pricing.md)
- [Blog & Technical Guides (Markdown)](https://thuecloud.vn/blog.md)
- [XML Sitemap](https://thuecloud.vn/sitemap.xml)
