您的位置:首页 > 运维架构 > Shell

使用Windows PowerShell查看系统信硬件信息-1

2013-09-10 16:54 225 查看
当你看到标题末尾的数字时,也许你心中第一个疑问就是这部分内容有几篇呢?说句实话,我心里也没谱,我只能说,我尽量将有用的计算机硬件信息都收录到这个大标题中,分段慢慢讲。这些信息,准确说不是Windows PowerShell取得的,是通过微软的Windows Management Instrumentation (WMI)来实现的。Windost PowerShell在这方面做的很成功,没有重复发明轮子,而是尽最大努力利用现有的一切技术来做到最好。
1. 查看计算机BIOS信息
我们首先来检查一下计算机的BIOS信息,BIOS就是基本输入输出系统,是在操作系统运行之前,对计算机进行检查设置的第一个软件。BIOS信息主要就是BIOS的类型、版本等,你可以使用如下命令来查看本地计算机上的Bios信息:
PS C:\> Get-WmiObject -Class Win32_BIOS
SMBIOSBIOSVersion : 6.00 PG
Manufacturer : Phoenix Technologies, LTD
Name : Phoenix - AwardBIOS v6.00PG
SerialNumber :
Version : Nvidia - 42302e31
这里你可以看到,生产商是Phoenix Technologies,版本是Nvidia的。
2. 查看计算机内存信息
内存信息往往是我们需要关注的地方,如何能够知道计算机的内存信息?您可以使用如下的命令:
PS C:\> Get-WmiObject -Class Win32_PhysicalMemory
Memory 0"
BankLabel : Bank0/1
Capacity : 268435456
Caption : 物理内存
CreationClassName : Win32_PhysicalMemory
DataWidth :
Description : 物理内存
DeviceLocator : A0
由于我使用的电脑有3根内存条,因此我删除了大部分显示的信息,不过我们可以看到一些我们关心的必要信息。
当你看到内存容量是268435456时候,是不是有点头痛呢?让我们再来简单编写一个脚本,计算计算机上的内存容量。代码如下:
PS C:\> Get-WmiObject -Class Win32_PhysicalMemory | %{$sum = 0} { $sum += $_.Capacity } {Write-Host ($sum / 1MB) "MB"}
1024 MB
原来计算机上有1GB的内存啊,真的是很方便。
3. 查看计算机处理器信息
很多时候,我们很好奇计算机上的处理器信息,例如:CPU的速度、时钟频率、缓存大小、CPU型号、CPU数量等。我们只要使用下面的命令就能了解计算机上的CPU信息啦:
PS C:\> Get-WmiObject -Class Win32_Processor
AddressWidth : 32
Architecture : 0
Caption : x86 Family 6 Model 10 Stepping 0
CpuStatus : 1
CreationClassName : Win32_Processor
CurrentClockSpeed : 1840
CurrentVoltage : 33
DataWidth : 32
Description : x86 Family 6 Model 10 Stepping 0
DeviceID : CPU0
ExtClock : 166
Family : 29
L2CacheSize : 512
L2CacheSpeed : 613
Level : 6
LoadPercentage : 42
Manufacturer : AuthenticAMD
MaxClockSpeed : 1840
Name : AMD Athlon(tm) XP 2500+
PowerManagementSupported : False
ProcessorType : 3
Revision : 2560
Role : CPU
SocketDesignation : Socket A
这里我做了一些删减,如果有多个CPU,那么每个CPU的这些信息都会被输出,确定CPU的数量也很容易,用下面的命令就能实现:
PS C:\> @(Get-WmiObject -Class Win32_Processor).count
4. 查看计算机显卡信息
PS C:\> Get-WmiObject -Class Win32_VideoController
AdapterCompatibility : ATI Technologies Inc.
AdapterDACType : Internal DAC(400MHz)
AdapterRAM : 268435456
Availability : 3
Caption : RADEON X1600 Series
ConfigManagerErrorCode : 0
ConfigManagerUserConfig : False
CreationClassName : Win32_VideoController
CurrentBitsPerPixel : 32
CurrentHorizontalResolution : 1440
CurrentNumberOfColors : 4294967296
CurrentNumberOfColumns : 0
CurrentNumberOfRows : 0
CurrentRefreshRate : 60
CurrentScanMode : 4
CurrentVerticalResolution : 900
Description : RADEON X1600 Series
DeviceID : VideoController1
DeviceSpecificPens : 4294967295
DitherType :
DriverDate : 20060719025814.810907-000
DriverVersion : 6.14.10.6626
InfSection : ati2mtag_RV530
InstalledDisplayDrivers : ati2dvag.dll
MaxRefreshRate : 75
MinRefreshRate : 56
Name : RADEON X1600 Series
NumberOfColorPlanes : 1
VideoArchitecture : 5
VideoMemoryType : 2
VideoModeDescription : 1440 x 900 x 4294967296 种颜色
VideoProcessor : Radeon X1600 Series AGP (0x71C2)
5. 查看计算机硬盘信息
在检查硬件信息的最后,我们来看看计算机的硬盘信息。
PS C:\> Get-WmiObject -Class Win32_DiskDrive
Partitions : 4
DeviceID : \\.\PHYSICALDRIVE0
Model : Maxtor 6Y080L0
Size : 81956689920
Caption : Maxtor 6Y080L0
Partitions代码分区的数量,Size表示磁盘的容量,哎这真是一块小硬盘啊。
http://os.51cto.com/art/200806/76197.htm
http://os.51cto.com/art/200806/76197_1.htm 我来补充一句:
怎么才能知道Class有那些内容呢?
get-wmiobject -List|findstr Wmi32
就能看到很多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: