Quantcast
Viewing all articles
Browse latest Browse all 240675

Re: list vms and portgroups

The code looks good. I don't see a reason to change it.

 

The Select-Object cmdlet selects properties from the networkadapters. @{N="VM";E={$_.Parent.Name}} is a calculated property. It is a PowerShell hashtable that contains two key-value pairs. It is short notation for @{Name="VM";Expression={$_.Parent.Name}}. The first key is Name and the first value is the string "VM". The second key is Expression and the value is the scriptblock {$_.Parent.Name}.

 

$_ is the current object in the pipeline. $_.Parent is the Parent property of the current object in the pipeline. In this case it is the Parent property of a networkadapter that contains the virtual machine object. $_.Parent.Name is the Name property of the $_.Parent property. Because the $_.Parent property contains a virtual machine object, the $_.Parent.Name property contains the name of a virtual machine.

 

I hope this exploination makes it clear to you.


Viewing all articles
Browse latest Browse all 240675

Trending Articles