how to add ESXi routs using the power shell on multiple hosts or a esxi cluster Connecting to vCenter
See Solved: Re: Add Static Route with get-esxcli - VMware Technology Network VMTN
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
you can try as below
Get-VMHost -PipelineVariable esx | ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$parms = @{
network = '192.168.102.0/24'
gateway = '192.168.3.1'
}
$esxcli.network.ip.route.ipv4.add.Invoke($parms)
$esxcli.network.ip.route.ipv4.list.Invoke()
}