需要具体查看某个类的成员,使用下面的命令(例如类"win32_process"):
可以看到每个有的成员是属性(Property),而有的则是方法(Method)。get-wmiobject -class win32_process -namespace "root/cimv2" | get-member
查看服务信息
get-wmiobject -class win32_service -namespace "root/cimv2" | format-list * <enter> 查看机器信息
get-wmiobject -class win32_computersystem | format-list * <enter>
在网络管理环境中的多数情况下,我们可能要查看不同的计算机信息,因此,就需要使用计算机这一参数,例如:
查询本地计算机的网络信息
$items = get-wmiObject -class win32_NetworkAdapterConfiguration '
-namespace "root/CIMV2" -ComputerName $name | where{$_.IPEnabled -eq “True”}
foreach($obj in $items) {
Write-Host "DHCP Enabled:" $obj.DHCPEnabled
Write-Host "IP Address:" $obj.IPAddress
Write-Host "Subnet Mask:" $obj.IPSubnet
Write-Host "Gateway:" $obj.DefaultIPGateway
Write-Host "MAC Address:" $ojb.MACAddress
}
例如:
foreach($obj in $items) {
Write-Host "DHCP Enabled:" $obj.DHCPEnabled
Write-Host "IP Address:" $obj.IPAddress
Write-Host "Subnet Mask:" $obj.IPSubnet
Write-Host "Gateway:" $obj.DefaultIPGateway
Write-Host "MAC Address:" $ojb.MACAddress
}
新闻热点
疑难解答
图片精选