2

I have the following snippet

Get-VM | select name, @{ Name = "IP Addresses"; Expression = { $_.Guest.IPAddress }} | Format-List

This outputs a fantastic list of servers and IP addresses however i notice some iPV6 addresses are truncated.

Name         : eg.example.com
IP Addresses : {192.168.100.18, 2a03:2658:1068:0:250:56ff:feaf:593f, fe80::2504:56ff:feaf:593f, 192.168.100.1...}

How can I expand this to output all address space? I have tried using -ExpandProperty but this seems to fail.

StackUser_py
  • 173
  • 1
  • 1
  • 6

2 Answers2

1

Join the elements of the list to a string:

... | select name, @{n='IP Addresses';e={$_.Guest.IPAddress -join ', '}} | ...
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
1

The data is there but PowerShell has truncated it on screen by only showing you the first 4 elements in the IP Addresses property array. If you want to leave the property as an array you could change the preference variable for $FormatEnumerationLimit. By default it is 4.

$FormatEnumerationLimit = -1

That will force it to display the entire array on screen. It would be a good idea to save the value before you change it in case you need to reverse.

$savedValue = $FormatEnumerationLimit
Matt
  • 45,022
  • 8
  • 78
  • 119