Beta 42

Research and Development

Menu

PowerShell - Finding Object Properties

Sometimes, you know the information you are after is present in some object property, but there are so many properties that it is a hassle to search for the one that holds the information.

In cases like this, you can convert the object to text lines, and then use Select-String to find the line (and the property) you are after:

PS> Get-WmiObject -Class Win32_NetworkAdapter | Out-String -Stream | Select-String Ethernet

AdapterType      : Ethernet 802.3
Name             : Apple Mobile Device Ethernet
Name             : Apple USB Ethernet Adapter
AdapterType      : Ethernet 802.3
AdapterType      : Ethernet 802.3
Name             : VirtualBox Host-Only Ethernet Adapter
Name             : Apple Mobile Device Ethernet

As it turns out, the information is present in two different properties: AdapterType as well as Name.