VMware Cloud Community
Pinball
Enthusiast
Enthusiast
Jump to solution

Export vm network and location details

Hi there

I'm faily new to PowerCli and due to a lack of understanding this seems to fail in all forms.

I'm trying to list VM-name, NetworkName, Cluster, ESX Host

The aim is to export this and then create a new source file to use and set a new NetworkName for each vm on a per host base.

Please asssit me with this.

Get-VM | Get-NetworkAdapter |
Select @{N="VM";E={$_.Parent.Name}},NetworkName,`
@{N="Cluster";E={Get-Cluster -VM $_}}, `
@{N="ESX Host";E={Get-VMHost -VM $_}}

The Name and NetworkName works but fighting to add the cluster and Host

Thanks

Johan

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try it this way

Get-VM | 
Select @{N="VM";E={$_.Name}}, 
@{N="NetworkName";E={Get-NetworkAdapter -VM $_ | Select -ExpandProperty Name}},
@{N="Cluster";E={Get-Cluster -VM $_  | Select -ExpandProperty Name}},
@{N="ESX Host";E={Get-VMHost -VM $_  | Select -ExpandProperty Name}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Try it this way

Get-VM | 
Select @{N="VM";E={$_.Name}}, 
@{N="NetworkName";E={Get-NetworkAdapter -VM $_ | Select -ExpandProperty Name}},
@{N="Cluster";E={Get-Cluster -VM $_  | Select -ExpandProperty Name}},
@{N="ESX Host";E={Get-VMHost -VM $_  | Select -ExpandProperty Name}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Pinball
Enthusiast
Enthusiast
Jump to solution

Thank you LucD for the Super quick response and such a simple answer.

0 Kudos
Pinball
Enthusiast
Enthusiast
Jump to solution

Sorry was a bit quick on the reply, but found the issue. Was looking for the NetworkName not Name.

Get-VM |
Select @{N="VM";E={$_.Name}},
@{N="NetworkName";E={Get-NetworkAdapter -VM $_ | Select -ExpandProperty NetworkName}},
@{N="Cluster";E={Get-Cluster -VM $_  | Select -ExpandProperty Name}},
@{N="ESX Host";E={Get-VMHost -VM $_  | Select -ExpandProperty Name}}
0 Kudos