VMware Cloud Community
vmk2014
Expert
Expert
Jump to solution

Can we pull the Network IP address, DNS and default gateway for the VM's from power cli ?

HI All,

Can we pull the Network IP address, DNS and default gateway for the VM's from power cli for the specific lists of VM's?  E.g. C:\temp\vmlist

thanks

vmk

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this.

It does require VMware Tools.

Get-VM -Name (Get-Content -Path C:\temp\list.txt) -PipelineVariable vm |

Select Name,

   @{N='Cluster';E={(Get-Cluster -VM $_).Name}},

   @{N='IP';E={$_.Guest.IPAddress -join '|'}},

   @{N='Gateway';E={$_.ExtensionData.Guest.IpStack.IpRouteConfig.IpRoute.Gateway.IpAddress | where {$_ -ne $null}}},

   @{N='DNS';E={$_.ExtensionData.Guest.IpStack.dnsconfig.ipaddress -join '|' }}


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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

Try like this.

It does require VMware Tools.

Get-VM -Name (Get-Content -Path C:\temp\list.txt) -PipelineVariable vm |

Select Name,

   @{N='Cluster';E={(Get-Cluster -VM $_).Name}},

   @{N='IP';E={$_.Guest.IPAddress -join '|'}},

   @{N='Gateway';E={$_.ExtensionData.Guest.IpStack.IpRouteConfig.IpRoute.Gateway.IpAddress | where {$_ -ne $null}}},

   @{N='DNS';E={$_.ExtensionData.Guest.IpStack.dnsconfig.ipaddress -join '|' }}


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

0 Kudos