O'Reilly logo

Pro Windows PowerShell by Hristo Deshev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

20.6. Querying Hardware Devices

The examples you have seen so far have dealt with software entities only: processes, services, and so on. WMI makes no distinction between hardware and software objects, and its tight integration with the Windows kernel allows it to manipulate all sorts of devices. We can use it to get information about different computers and their hardware configurations.

For example, we can get information about the currently installed hard drives by querying the available Win32_DiskDrive objects. Here is what I get on my system:

PS> gwmi -class Win32_DiskDrive Partitions : 2 DeviceID : \\.\PHYSICALDRIVE0 Model : ST3320620AS ATA Device Size : 320070320640 Caption : ST3320620AS ATA Device Partitions : 1 DeviceID : \\.\PHYSICALDRIVE1 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required