Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180923

gettingiproutes_and_creatingstaticroutes_powercli

$
0
0

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

 

 

   }

 

 

   }

 

   }


Viewing all articles
Browse latest Browse all 180923

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>