一个能快速读取出电脑性能,配置的脚本
<# Windows System & Hardware Info Collector Terminal Output Only / No File / No Disk Speed Test #>
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $ErrorActionPreference = "SilentlyContinue"
function Title($t) { Write-Host "`n$t" -ForegroundColor Green }
Write-Host "========================================" -ForegroundColor Cyan Write-Host " Windows System & Hardware Info Tool " -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan
# ===================== # [1] System # ===================== Title "[1] System" $os = Get-CimInstance Win32_OperatingSystem $boot = [Management.ManagementDateTimeConverter]::ToDateTime($os.LastBootUpTime) $uptime = [math]::Round((New-TimeSpan $boot (Get-Date)).TotalHours, 2)
Write-Host "Name : $($os.Caption)" Write-Host "Version : $($os.Version)" Write-Host "Build : $($os.BuildNumber)" Write-Host "Architecture : $($os.OSArchitecture)" Write-Host "UptimeHours : $uptime"
# ===================== # [2] CPU # ===================== Title "[2] CPU" $cpu = Get-CimInstance Win32_Processor $cpuLoad = (Get-Counter '\Processor(_Total)\% Processor Time').CounterSamples.CookedValue
Write-Host "Name : $($cpu.Name.Trim())" Write-Host "Cores : $($cpu.NumberOfCores)" Write-Host "LogicalProcessors : $($cpu.NumberOfLogicalProcessors)" Write-Host "MaxGHz : $([math]::Round($cpu.MaxClockSpeed / 1000, 2))" Write-Host "UsagePercent : $([math]::Round($cpuLoad, 2))" Write-Host "Virtualization : $($cpu.VirtualizationFirmwareEnabled)"
# ===================== # [3] Memory # ===================== Title "[3] Memory" $totalMem = (Get-CimInstance Win32_PhysicalMemory | Measure-Object Capacity -Sum).Sum / 1GB $availMem = (Get-Counter '\Memory\Available MBytes').CounterSamples.CookedValue / 1024 $usedMem = $totalMem - $availMem
Write-Host "TotalGB : $([math]::Round($totalMem, 2))" Write-Host "UsedGB : $([math]::Round($usedMem, 2))" Write-Host "AvailableGB : $([math]::Round($availMem, 2))" Write-Host "UsageRate : $([math]::Round(($usedMem / $totalMem) * 100, 2)) %"
# ===================== # [4] GPU # ===================== Title "[4] GPU" $gpus = Get-CimInstance Win32_VideoController foreach ($g in $gpus) { $vram = if ($g.AdapterRAM) { [math]::Round($g.AdapterRAM / 1GB, 2) } else { "Unknown" } Write-Host "GPU : $($g.Name.Trim()) | VRAM : $vram GB" }
# ===================== # [5] Disk (Capacity Only) # ===================== Title "[5] Disk" $disks = Get-CimInstance Win32_LogicalDisk | Where-Object DriveType -eq 3
foreach ($d in $disks) { $total = [math]::Round($d.Size / 1GB, 2) $free = [math]::Round($d.FreeSpace / 1GB, 2) Write-Host "Drive $($d.DeviceID) | Total: $total GB | Free: $free GB" }
# ===================== # [6] Network (Detailed) # ===================== Title "[6] Network"
$adapters = Get-NetIPConfiguration | Where-Object { $_.IPv4Address -and $_.NetAdapter.Status -eq "Up" }
foreach ($a in $adapters) {
$ipList = $a.IPv4Address.IPAddress -join ", " $gw = if ($a.IPv4DefaultGateway) { $a.IPv4DefaultGateway.NextHop } else { "None" }
$type = switch -Wildcard ($a.NetAdapter.InterfaceDescription) { "*Wi-Fi*" { "Wi-Fi" } "*Wireless*" { "Wi-Fi" } "*Ethernet*" { "Ethernet" } "*Hyper-V*" { "Virtual" } "*Virtual*" { "Virtual" } "*VPN*" { "VPN" } "*TAP*" { "VPN" } default { "Unknown" } }
Write-Host "----------------------------------------" -ForegroundColor DarkGray Write-Host "Adapter Name : $($a.NetAdapter.Name)" Write-Host "Description : $($a.NetAdapter.InterfaceDescription)" Write-Host "Type : $type" Write-Host "MAC Address : $($a.NetAdapter.MacAddress)" Write-Host "IPv4 Address : $ipList" Write-Host "Gateway : $gw" }
Write-Host "`n[ Public IP ]" -ForegroundColor Yellow try { $publicIP = Invoke-RestMethod -Uri "https://api.ipify.org" Write-Host "Public IP : $publicIP" } catch { Write-Host "Public IP : Unable to fetch" }
Write-Host "`nDone." -ForegroundColor Cyan
|
保存为.ps1运行即可。
管理员 PowerShell → cd 到脚本目录 → Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass → .\system_info.ps1
如果将其挂在一个网站上面,怎么一行命令直接执行
powershell -ExecutionPolicy Bypass -Command "irm https://example.com/system_info.ps1 | iex"
|