复制代码
- get-wmiObject -list -namespace "root\CIMV2"
PS E:\> get-wmiObject -list -namespace "root\CIMV2" NameSpace: ROOT\CIMV2 Name Methods Properties ---- ------- ---------- __SystemClass {} {} __thisNAMESPACE {} {SECURITY_DESCRIPTOR} __NAMESPACE {} {Name} __Provider {} {Name} __Win32Provider {} {ClientLoadableCLSID, CLSID, Concurrency, DefaultMachineName...} __ProviderRegistration {} {provider} |
复制代码
- get-wmiobject -class win32_process -namespace "root\cimv2"
PS E:\> get-wmiobject -class win32_process -namespace "root\cimv2" __GENUS : 2 __CLASS : Win32_Process __SUPERCLASS : CIM_Process __DYNASTY : CIM_ManagedSystemElement __RELPATH : Win32_Process.Handle="0" __PROPERTY_COUNT : 45 |
好了,现在来具体操作,查看具体信息。复制代码
- get-wmiObject -list -namespace "root\CIMV2" -computername 计算机名
运行结果:复制代码
- get-wmiobject -class win32_bios -namespace "root\cimv2"
PS E:\> get-wmiobject -class win32_bios -namespace "root\cimv2" SMBIOSBIOSVersion : 8HET50WW(1.23) Manufacturer : LENOVO Name : Default System BIOS SerialNumber : R7K8H9A Version : LENOVO - 123 |
查看机器信息复制代码
- get-wmiobject -class win32_service -namespace "root\cimv2" | format-list *
在网络管理环境中的多数情况下,我们可能要查看不同的计算机信息,因此,就需要使用计算机这一参数,例如:复制代码
- get-wmiobject -class win32_computersystem | format-list *
如果查询对象是其他机器,只需给变量"$name"赋与其他值即可。复制代码
- $name="."
- $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
- }
配合更多的查询命令,便可以方便的写出一个查询计算机信息的脚本,在本教程的结束部分,我会尽可能多的提供各种常用脚本。本节内容就先写到这里。复制代码
- $name=read-host "Enter Computer Name"
- write-host "Computer:"$name
- $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
- }
欢迎光临 批处理之家 (http://bathome.net./) | Powered by Discuz! 7.2 |