VMware Cloud Community
bingzofo
Contributor
Contributor
Jump to solution

Get ESXi routing table powerCli

Hi,

I want to ask is it a way how to get ESXi routing table via powerCLI from various (69) ESXi host?

thanks

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

If you need to stay with the older version, you could do

foreach($esx in Get-VMHost){

    $esxcli = Get-EsxCli -VMHost $esx

    $esxcli.network.ip.route.ipv4.list() |

    select @{N='VMHost';E={$esx.Name}},*

}


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

View solution in original post

8 Replies
LucD
Leadership
Leadership
Jump to solution

Does this bring what you want?

$esxcli = Get-EsxCli -VMHost MyEsx -V2

$esxcli.network.ip.route.ipv4.list.Invoke()


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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

And if you want this for all your ESXi nodes, you could do something like this

foreach($esx in Get-VMHost){

    $esxcli = Get-EsxCli -VMHost $esx -V2

    $esxcli.network.ip.route.ipv4.list.Invoke() |

    select @{N='VMHost';E={$esx.Name}},*

}


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

bingzofo
Contributor
Contributor
Jump to solution

getting error

You cannot call a method on a null-valued expression.

At D:\_ivan\esxi-routing.ps1:3 char:5

+     $esxcli.network.ip.route.ipv4.list.Invoke() |

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Does Get-VMHost return anything?
Are you connected to the vCenter?


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

0 Kudos
bingzofo
Contributor
Contributor
Jump to solution

yes, I am, Get-vmhost its working normally.

Get-EsxCli : A parameter cannot be found that matches parameter name 'V2'.

At D:\_ivan\esxi-routing.ps1:2 char:39

+     $esxcli = Get-EsxCli -VMHost $esx -V2

+                                       ~~~

    + CategoryInfo          : InvalidArgument: (:) [Get-EsxCli], ParameterBind

   ingException

    + FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCo

   re.Cmdlets.Commands.GetEsxCli

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Looks like you are on an older PowerCLI version (do a Get-PowerCLIVersion).

I would suggest to upgrade if possible.


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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you need to stay with the older version, you could do

foreach($esx in Get-VMHost){

    $esxcli = Get-EsxCli -VMHost $esx

    $esxcli.network.ip.route.ipv4.list() |

    select @{N='VMHost';E={$esx.Name}},*

}


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

bingzofo
Contributor
Contributor
Jump to solution

yes, that was it, thank you!!!!

0 Kudos