Avatar of jmachado81
jmachado81
 asked on

ESXi and PowerCLI

I have created a 2 node vsan cluster with a witness.  The two physical hosts are interconnected with 10gb links and the vsan vmkernel resides on that particular vswitch.  I leave the mgmt on the default vSwitch0 which uses vmk0.

I'm looking for a way to script in powercli/powershell adding a route to the esxi hosts so that it can communicate with the witness.

$HostNameFQDN = xyz.domain.com

This outputs nothing on my system currently but it seems like i'm really close.
$Host_Gateway = Get-VMHost -Name $HostNameFQDN | Get-VMHostNetworkAdapter | select VMKernelGatway

New-VMHostRoute -VMHost $HostNameFQDN -Destination 172.23.0.0 -Gateway $Host_Gateway -PrefixLength 20

Would somebody be able to assist with getting this to work, correctly?  I've also noticed that the Get-network commands do not work in Powershell ISE but they do in the regular powershell window.

Thanks in advance.
Powershell* vsan* PowerCLIVMware

Avatar of undefined
Last Comment
Qlemo

8/22/2022 - Mon
SOLUTION
Pber

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jmachado81

ASKER
How can I pull the existing gateway from the vmk0 VMKernel (mgmt)?  When i run the below the output is blank.

Get-VMHost -Name $HostNameFQDN | Get-VMHostNetworkAdapter | select VMKernelGatway
Pber

Try this:

Get-VMHost -Name $HostNameFQDN | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Select VMKernelGateway
ASKER CERTIFIED SOLUTION
Pber

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jmachado81

ASKER
This displays all vmkernels instead of just vmk0 but I'll push this line up in my script so there is only one vmk at the time of running.  Thanks
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Qlemo

The above script works, but is "wrong" in it doing too much. A simple
$Host_Gateway = Get-VMHost -Name $HostNameFQDN | Get-VMHostNetwork | Select VMKernelGateway

Open in new window

is sufficient. The main point has been exchanging Get-VMHostNetworkAdapter by Get-VMHostNetwork.