How to ONLY get property value

Solution 1:

Using your example, you'd type $Computer.IPAddressToString to return the array of IP addresses. If there is only 1 IP address for that hostname, then that's all there is. However, a hostname may have many addresses, and that's why it's an array. So if you only want to see the first IP address in the array, you could type $Computer.IPAddressToString[0]

Solution 2:

Replace

| select IPAddressToString

With (Powershell 2.0+)

| select -First 1 -ExpandProperty IPAddressToString

Or, in the case where you want to work with an array

| select -ExpandProperty IPAddressToString

This will give you an array of strings, so if you want individual addresses, use something like

([System.Net.Dns]::GetHostAddresses($computer) | select -ExpandProperty IPAddressToString)[0]

Solution 3:

add ().IpAddressToString

([Net.Dns]::GetHostAddresses('Server1')).IpAddressToString