Hi Luc,
i thought of starting a new discussion associated below thred
creating vmkernel port group_powercli
vmkernel ports for replication has already been created and assigned to replication vlan as per above post. .
created following function that will find iproute on each esxi host of a cluster and at the same time add new static route to each esxi in same cluster.
can you please validate the orange part of the code .(whether datatype string is correct ?
function get-staticroute {
[cmdletbinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[string]$clustername,
[Parameter(Mandatory=$true)]
[string]$destinationnetwork,
[Parameter(Mandatory=$true)]
[string]$prefixlength,
[Parameter(Mandatory=$true)]
[string]$gateway
)
#$clustername=read-host "clustername"
$cluster=get-cluster $clustername
$vmhosts=get-vmhost -location $cluster
$fragments = @()
foreach($vmhost in $vmhosts)
{
$esxcli = Get-EsxCli -VMHost $vmhost -V2
$staticrouteinfo=$esxcli.network.ip.route.ipv4.list.Invoke()
$fragments += $vmhost.name
$fragments += $staticrouteinfo
}
$fragments
$newstaticroute=read-host "would yu like to add static route to all esxi in cluster"
if($newstaticroute -eq 'y')
{
foreach($h in $vmhosts)
{
#New-VMHostRoute -vmhost $h -destination 172.16.9.0 -PrefixLength 25 -Gateway 172.16.9.1 -WhatIf
New-VMHostRoute -vmhost $h -destination $destinationnetwork -PrefixLength $prefixlength -Gateway $gateway -WhatIf
}
}
}
You can do something like this
network = "$destinationnetwork/$prefixlength"
gateway = $gateway
}
$esxcli.network.ip.route.ipv4.add.Invoke($route)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, that should work.
Just wondering why you don't use $esxcli as well for creating the new route?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
can yu suggest that way also?
You can do something like this
network = "$destinationnetwork/$prefixlength"
gateway = $gateway
}
$esxcli.network.ip.route.ipv4.add.Invoke($route)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thnaksLuc.