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

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 ', ', 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!