VMware Cloud Community
rock0n
VMware Employee
VMware Employee
Jump to solution

Question on Hashtables

Hi there,

i've two (simple) questions. Maybe anybody can give me an (simple) answer 🙂

This is the statement:

$vm | select Name, @{N="IPAddress"; E={ $_ | Get-VMGuest | select -ExpandProperty IP*}}

The Questions.

1. Why do i have to use E in the middle of the statement?

2  What does E stand for?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

With @{} you are creating a hash table. The N stands for Name and the E for Expression. So you could also write:

$vm | select Name, @{Name="IPAddress"; Expression={ $_ | Get-VMGuest | select -ExpandProperty IP*}}


Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
4 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

With @{} you are creating a hash table. The N stands for Name and the E for Expression. So you could also write:

$vm | select Name, @{Name="IPAddress"; Expression={ $_ | Get-VMGuest | select -ExpandProperty IP*}}


Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
rock0n
VMware Employee
VMware Employee
Jump to solution

3 minutes... Awesome 🙂

Thank you!

0 Kudos
mattboren
Expert
Expert
Jump to solution

Hello, rock0n-

Robert has it right on for you.

There is some good info on this hash table and how it is used for "calculated properties" in the TechNet page at http://technet.microsoft.com/en-us/library/ff730948.aspx.

Also, getting full help on the Format-Table cmdlet talks about the other valid keys for a calculated property hash table (see the -Property portion), like Width and Alignment.

rock0n
VMware Employee
VMware Employee
Jump to solution

Hi mattboren,

that was the "dumb and outa vmware" example i was looking for 😉

thanks!

0 Kudos