Sub
WMI()
Dim
oWMISrvEx
As
Object
Dim
oWMIObjSet
As
Object
Dim
oWMIObjEx
As
Object
Dim
oWMIProp
As
Object
Dim
sWQL
As
String
Dim
n
As
Long
sWQL =
"Select * From Win32_NetworkAdapterConfiguration"
Set
oWMISrvEx = GetObject(
"winmgmts:root/CIMV2"
)
Set
oWMIObjSet = oWMISrvEx.ExecQuery(sWQL)
For
Each
oWMIObjEx
In
oWMIObjSet
If
Not
IsNull(oWMIObjEx.IPAddress)
Then
Debug.Print
"IP:"
; oWMIObjEx.IPAddress(0)
Debug.Print
"Host name:"
; oWMIObjEx.DNSHostName
For
Each
oWMIProp
In
oWMIObjEx.Properties_
If
IsArray(oWMIProp.Value)
Then
For
n = LBound(oWMIProp.Value)
To
UBound(oWMIProp.Value)
Debug.Print oWMIProp.Name &
"("
& n &
")"
, oWMIProp.Value(n)
Next
Else
Debug.Print oWMIProp.Name, oWMIProp.Value
End
If
Next
End
If
Next
End
Sub
Want to see more?
Here is a workbook that facilitates exploring several hundred classes containing information about our CPU, disk drives, memory, operating system, applications, users, and much, much more.
And
it can query remote PCs and servers too, assuming you have the credentials.
Uses for WMI Query.xlsm
Inventory all PCs in a network including all hardware and software using:
Win32_SystemEnclosure - PC
Win32_LogicalDisk - Disks with capacities and free space.
Win32_Processor - CPU Specs
Win32_PhysicalMemoryArray - RAM/Installed Memory size
Win32_VideoController - Graphics adapter and settings
Win32_OnBoardDevice - Motherboard devices
Win32_OperatingSystem - Which version of Windows with Serial Number
WIn32_Printer - Installed Printers
Win32_Product - Installed Software
WIn32_Account - List all User Accounts on a PC or Domain
Win32_ComputerSystem - See who is currently using a remote PC (also Win32_LoggedOnUser)
Win32_BaseService - List services running (or stopped) on any PC along with the service
And
hundreds more!