Turning Multi-Value WMI Properties into Text

by Nov 24, 2011

When you read multi-valued information from WMI or any other source, for example, network adapter IP addresses, this information is returned as a multi line string:

PS> Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter 'IPEnabled=true' | Select-Object -ExpandProperty IPAddress
78.64.118.150
fe80::ad62:ac4d:4dea:936d

If you want to turn this into a list, use the operator -join:

PS> (Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter 'IPEnabled=true' | Select-Object -ExpandProperty IPAddress) -join ', '
78.64.118.150, fe80::ad62:ac4d:4dea:936d

It expects the multi line (array) data on its left side and the delimiter you want to use to separate the values on its right side.

Twitter This Tip!
ReTweet this Tip!