1. 程式人生 > >一鍵查詢系統Windows基本信息的PowerShell腳本

一鍵查詢系統Windows基本信息的PowerShell腳本

shell data pac 窗口 圖片 hang byte use shadow

直接發一個簡單的查詢系統基本信息的PS腳本吧,無聊寫的,我用的語法都是通俗易懂的。應該沒有難得地方,唯一一個就是調用了ws的窗口。

技術分享圖片

<#
Simple System Info tool
Author: Roger, Zhang
Version: 1.0
#>

$disk = Get-WmiObject Win32_LogicalDisk -ComputerName ‘localhost‘ -Filter "DeviceID=‘C:‘"
$drive = $disk.DeviceID
$free = $disk.freespace
$size = $disk.size
$used = 1-$free/$size

$percent = “{0:0.0%}” -f $used
$os = Get-WmiObject -Class Win32_OperatingSystem
$version = $os.version
$ip = (Get-NetIPAddress -interfacealias Ethernet* -AddressFamily IPv4).ipaddress
$user = $env:USERNAME
$a=(get-wmiobject -class Win32_PhysicalMemory -namespace "root\cimv2").Capacity /1gb
$b= "{0:0.0}" -f (((get-wmiobject -class Win32_PerfFormattedData_PerfOS_Memory -namespace "root\cimv2").AvailableMBytes) / 1014)
$mem=$a-$b
$cpus = (Get-WmiObject Win32_Processor).count
$msg = "
User ‘$user‘
Hostname ‘$env:computername‘
CPU: $cpus Core
Memory free $mem of $a GB
IPaddress ‘$ip‘
Drive‘$drive‘used‘$percent‘
OS ‘Windows$version‘
"
write-host $msg
$ws = New-Object -ComObject wscript.shell
$wsr = $ws.popup("$msg","999","SystemInfo",0 + 64)

一鍵查詢系統Windows基本信息的PowerShell腳本