Try
$myResultSet | Select-Object -First 1 IPAddress
Your result set is a collection of some type. The Select-Object
cmdlet is taking the first item in that collection and then filtering to only the IPAddress
property which is then displayed.
On my machine the output of the above command looks like this. Yours will likely differ in that the address returned will be different
IPAddress
---------
fe80::5581:4fbc:fc22:ec79%13
You get the table because by default PowerShell puts the output through Format-Table
to make a nice display.
To access just the IP address itself you can modify the expression slightly:
$myResultSet.IPAddress|Select-Object -First 1
or, by using dot notation and an index into the collection you can avoid using Select-Object
entirely like so:
$myResultSet[0].IPAddress
The above refers directly to the IPAddress
property of the first item in the $myResultSet
collection, which has an index of zero hence $myResultSet[0]
Either of these will return just the IP address itself like so:
fe80::5581:4fbc:fc22:ec79%13
you could try creating a tupple: http://blogs.technet.com/b/heyscriptingguy/archive/2014/09/02/using-a-tuple-in-powershell.aspx Then you can access them with $var.Item1 or $var.Item2
– Frank Thomas – 2015-05-03T22:24:14.480Tried that, doesn't seem to parse it. It seems
IPAddresses
the piece of a tuple already, so you can't break it down further than that. – dthree – 2015-05-03T22:31:56.620