Script kiểm tra nhanh thông tin máy tính (PowerShell)
Xuất tên máy, hệ điều hành, CPU, RAM, ổ cứng, IP, MAC và số Serial chỉ với một lệnh — tiện cho kiểm kê tài sản IT.
- Nhấp đúp file
script-kiem-tra-thong-tin-may-tinh.cmd. - Nếu hiện Windows protected your PC: bấm More info → Run anyway (file tải từ Internet).
- Dùng bản
.ps1? Máy đặt ExecutionPolicy AllSigned/Restricted sẽ chặn (mở lên rồi tắt). Chạy bằng lệnh:powershell -ExecutionPolicy Bypass -File .\script-kiem-tra-thong-tin-may-tinh.ps1
⚠ Đọc kỹ nội dung script trước khi chạy — nội dung đầy đủ ở khung bên dưới.
$cs = Get-CimInstance Win32_ComputerSystem
$os = Get-CimInstance Win32_OperatingSystem
$cpu = Get-CimInstance Win32_Processor | Select-Object -First 1
$bios = Get-CimInstance Win32_BIOS
$net = Get-NetIPConfiguration | Where-Object { $_.IPv4DefaultGateway }
$info = [ordered]@{
"Tên máy" = $env:COMPUTERNAME
"Người dùng" = $env:USERNAME
"Hãng/Model" = "$($cs.Manufacturer) $($cs.Model)"
"Serial" = $bios.SerialNumber
"Hệ điều hành"= "$($os.Caption) ($($os.OSArchitecture)) build $($os.BuildNumber)"
"CPU" = $cpu.Name
"RAM (GB)" = [math]::Round($cs.TotalPhysicalMemory / 1GB, 1)
"IP" = ($net.IPv4Address.IPAddress -join ", ")
"MAC" = ($net | ForEach-Object { (Get-NetAdapter -InterfaceIndex $_.InterfaceIndex).MacAddress }) -join ", "
"Gateway" = ($net.IPv4DefaultGateway.NextHop -join ", ")
"DNS" = (($net.DNSServer | Where-Object AddressFamily -eq 2).ServerAddresses -join ", ")
}
Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" | ForEach-Object {
$info["Ổ $($_.DeviceID)"] = "{0:N1} GB trống / {1:N1} GB" -f ($_.FreeSpace/1GB), ($_.Size/1GB)
}
$out = $info.GetEnumerator() | ForEach-Object { "{0,-14}: {1}" -f $_.Key, $_.Value }
$out | Write-Host
$file = Join-Path ([Environment]::GetFolderPath("Desktop")) "ThongTinMay_$env:COMPUTERNAME.txt"
$out | Out-File $file -Encoding utf8
Write-Host "`nĐã lưu: $file" -ForegroundColor Green
Tính năng
- Lấy thông tin phần cứng: CPU, RAM, ổ đĩa, Serial (BIOS)
- Lấy thông tin mạng: IP, MAC, Gateway, DNS
- Xuất ra màn hình và lưu file
.txttrên Desktop
Cách dùng
- Copy đoạn script bên dưới, lưu thành
ThongTinMay.ps1 - Chuột phải → Run with PowerShell
- Nếu bị chặn, chạy trước lệnh:
Set-ExecutionPolicy -Scope Process Bypass
Mẹo: chạy qua GPO/Intune để gom thông tin toàn bộ máy trong công ty.
Bài liên quan
Tool phân tích lỗi màn hình xanh (BSOD)
Liệt kê các lần màn hình xanh gần đây, mã lỗi (bugcheck), các lần tắt máy đột ngột, file minidump và gợi ý cách xử lý theo từng mã lỗi.
# Phân tích màn hình xanh (BSOD) — chạy với quyền Administrator để đọc đủ nhật ký
$tips = [ordered]@{
'0x000000ef' = 'CRITICAL_PROCESS_DIED — file hệ thống hỏng: chạy sfc /scannow và DISM /Online /Cleanup-Image /RestoreHealth'
Kiểm tra bản quyền Windows & Office
Xem Windows, Office đã kích hoạt chưa, loại key (Retail/OEM/Volume), 5 ký tự cuối của key và ngày hết hạn — chỉ đọc thông tin, không thay đổi hệ thống.
# Kiểm tra trạng thái bản quyền Windows & Office — CHỈ ĐỌC, không thay đổi hệ thống
$statusText = @{ 0='Unlicensed (chưa có bản quyền)'; 1='Licensed (đã kích hoạt)'; 2='OOB Grace'; 3='OOT Grace';
4='Non-Genuine Grace'; 5='Notification (chưa kích hoạt)'; 6='Extended Grace' }
Sửa lỗi kết nối máy in share: 0x0000011b, 0x00000709, 0x0000007c
Script xử lý các lỗi "Windows cannot connect to the printer" phổ biến khi kết nối máy in chia sẻ trong LAN — chạy trên máy chủ chia sẻ hoặc máy con.
# Sửa lỗi kết nối máy in chia sẻ — cần quyền Administrator # Nhấp đúp bản .cmd để chọn chế độ, hoặc chạy trực tiếp: # .\sua-loi-ket-noi-may-in-share-11b-709.ps1 -Role Client -Printer \\PC-KETOAN\Canon2900
Tool quét virus bằng Microsoft Defender (có menu)
Cập nhật mẫu virus, chọn quét nhanh / toàn bộ / USB / quét ngoại tuyến, rồi liệt kê mối đe doạ đã phát hiện — dùng Defender có sẵn trên Windows, miễn phí.
# Quét virus bằng Microsoft Defender — chạy với quyền Administrator
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole('Administrators')) {
Start-Process powershell "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
Bình luận (1)