Powershell中使用WMI工具例子
支持所有版本
wmi是一个强大的技术:只需要简单的指定一个wmi类名就能返回它类的所有实例:
ps> get-wmiobject -class win32_bios
smbiosbiosversion : 76cn27ww
manufacturer : lenovo
name : 76cn27ww
serialnumber : 1006250300406
version : lenovo - 1
你如何知道它有哪些类呢?这里有一款查找工具:
function find-wmiclass
{
param
(
[parameter(mandatory=$true)]
$searchterm = 'resolution'
)
get-wmiobject -class * -list |
where-object { $_.properties.count -ge 3 } |
where-object { $_.name -notlike 'win32_perf*' } |
where-object {
$listofnames = $_.properties | select-object -expandproperty name
($listofnames -like "*$searchterm*") -ne $null
} |
sort-object -property name
}
设置搜索条件后,代码将搜索出包含指定属性名的类(还可以通过通配符扩大搜索范围)
下面将找出所有包含“resolution”结尾的wmi类:
ps> find-wmiclass -searchterm *resolution
namespace: root\cimv2
name methods properties
---- ------- ----------
cim_cachememory {setpowerstate, r... {access, additionalerr...
cim_currentsensor {setpowerstate, r... {accuracy, availabilit...
cim_flatpanel {setpowerstate, r... {availability, caption...
cim_memory {setpowerstate, r... {access, additionalerr...
cim_monitorresolution {} {caption, description,...
cim_nonvolatilestorage {setpowerstate, r... {access, additionalerr...
cim_numericsensor {setpowerstate, r... {accuracy, availabilit...
cim_pcvideocontroller {setpowerstate, r... {acceleratorcapabiliti...
cim_pointingdevice {setpowerstate, r... {availability, caption...
cim_printer {setpowerstate, r... {availability, availab...
cim_tachometer {setpowerstate, r... {accuracy, availabilit...
cim_temperaturesensor {setpowerstate, r... {accuracy, availabilit...
cim_videocontroller {setpowerstate, r... {acceleratorcapabiliti...
cim_videocontrollerresolution {} {caption, description,...
cim_volatilestorage {setpowerstate, r... {access, additionalerr...
cim_voltagesensor {setpowerstate, r... {accuracy, availabilit...
win32_cachememory {setpowerstate, r... {access, additionalerr...
win32_currentprobe {setpowerstate, r... {accuracy, availabilit...
win32_displaycontrollerconfigura... {} {bitsperpixel, caption...
win32_memoryarray {setpowerstate, r... {access, additionalerr...
win32_memorydevice {setpowerstate, r... {access, additionalerr...
win32_networkadapterconfiguration {enabledhcp, rene... {arpalwayssourceroute,...
win32_pointingdevice {setpowerstate, r... {availability, caption...
win32_printer {setpowerstate, r... {attributes, availabil...
win32_printerconfiguration {} {bitsperpel, caption, ...
win32_smbiosmemory {setpowerstate, r... {access, additionalerr...
win32_temperatureprobe {setpowerstate, r... {accuracy, availabilit...
win32_videoconfiguration {} {actualcolorresolution...
win32_videocontroller {setpowerstate, r... {acceleratorcapabiliti...
win32_voltageprobe {setpowerstate, r... {accuracy, availabilit...
接着,就可以使用类名查看它的有效数据啦:
ps> get-wmiobject -class cim_cachememory | select-object -property *
上一篇: 让2个DIV居中并排显示_经验交流
下一篇: 智能家居语音控制系统的设计与实现
推荐阅读
-
CorelDRAW中手绘工具的使用方法和操作技巧介绍
-
cdr中变形工具如何使用推拉变形?
-
ai中怎么使用网格工具画卡通苹果?
-
CorelDRAW10中的色彩泊坞窗工具使用详解
-
Win7系统中的命令行sxstrace.exe工具的使用方法
-
微信小程序 image组件binderror使用例子与js中的onerror区别
-
VMware Workstation/Fusion 中安装 Fedora 23/24 及其他 Linux 系统时使用 Open VM Tools 代替 VMware Tools 增强工具的方法
-
CDR中贝塞尔工具如何使用?贝塞尔工具使用方法介绍
-
CDR中缩放工具如何使用?缩放工具使用方法介绍
-
PS中模糊/锐化/涂抹/减淡等工具的使用方法