Automation

 View Only
  • 1.  Set Vmotion IP in VMkernel adapters through powercli

    Posted Jul 08, 2020 05:39 AM

    LucDJosh26ctech930DaryllKrisVMware {code}

    Is it possible to set the vmotion IP in vmkernel adapters for esxi host through powercli ?



  • 2.  RE: Set Vmotion IP in VMkernel adapters through powercli

    Posted Jul 08, 2020 06:03 AM

    You could do something like this

    Get-VMHost -Name MyEsx | Get-VMHostNetworkAdapter -VMKernel |

    where{$_.VMotionEnabled} |

    Set-VMHostNetworkAdapter -IP 192.168.1.11 -Confirm:$false



  • 3.  RE: Set Vmotion IP in VMkernel adapters through powercli

    Posted Jul 08, 2020 07:37 AM

    No it didn't work. The task is to add host networking where its done in 4 steps.

    1. Selecting connection type - VMkernel network adapter

    2. Selecting target device -existing network (where I have to point it to the network with name vmotion)

    3. a.Port properties - Have to select vmotion from the available services.

        b. IPV4 settings - Have to give IP & subnet mask (255.255.254.0)

    4. Ready to finish - Finish



  • 4.  RE: Set Vmotion IP in VMkernel adapters through powercli

    Posted Jul 08, 2020 08:01 AM

    That is way beyond your original question of changing the IP address on a vMotion vmkernel.
    Btw, my code does work to change the IP address of a vmkernel which is enabled for vMotion.



  • 5.  RE: Set Vmotion IP in VMkernel adapters through powercli

    Posted Jul 08, 2020 08:22 AM

    I'm not sure anymore what you actually want to do.

    Are you creating a new vmkernel or adapting an existing one?



  • 6.  RE: Set Vmotion IP in VMkernel adapters through powercli

    Posted Jul 08, 2020 08:27 AM

    Yeah creating a new vmkernel and point it to existing vmotion network for the cluster.

    This is what I'm talking about.



  • 7.  RE: Set Vmotion IP in VMkernel adapters through powercli
    Best Answer

    Posted Jul 08, 2020 08:58 AM

    Ok, then the following should do the trick.
    I didn't include the NetworkStack, if you need to specify that it will require another parameter.

    PS: I used 'splatting' to store the parameters for the cmdlet in a hash table.

    $esxName = 'MyEsx'

    $switchName = 'MySw'

    $pgName = 'vmotion'

    $ip = '192.168.1.111'

    $mask = '255.255.254.0'


    $esx = Get-VMHost -Name $esxName

    $sw = Get-VirtualSwitch -VMHost $esx -Name $switchName

    $pg = Get-VirtualPortGroup -Name $pgName -VirtualSwitch $sw

    $sVmk = @{

         VMHost = $esx

         VirtualSwitch = $sw

         PortGroup =  $pg

         VMotionEnabled = $true

         IP = $ip

         SubnetMask = $mask

         Confirm = $false

    }

    New-VMHostNetworkAdapter @sVmk



  • 8.  RE: Set Vmotion IP in VMkernel adapters through powercli

    Posted Jul 08, 2020 09:37 AM

    The command didn't work as the network label is not specified. Please refer the above screenshot which is taken from an esx host where this is already created. Like this I have to create vmkernel for new hosts manually from VC, which is time consuming task. :smileysad:

    Network Label is pointing to the vmotion network for that particular cluster. Switch indicates the cluster name. So the network label would be ESXC1010-ESX-VMOTION-34(ESXC1010-MSL-APP-WINDOWS) as per the below screenshot.

    In your command you have mentioned, $switchName = 'MySw'

    Here in my case which should be the MySw value? I assumed it is vmk3 as per the above screen shot. I'm not sure.

    PS C:\Windows\system32> $esxName = 'xyz.contoso.net'

    $switchName = 'vmk3'

    $pgName = 'vmotion'

    $ip = 'x.x.x.x'

    $mask = '255.255.254.0'

    $esx = Get-VMHost -Name $esxName

    $sw = Get-VirtualSwitch -VMHost $esx -Name $switchName

    $pg = Get-VirtualPortGroup -Name $pgName -VirtualSwitch $sw

    $sVmk = @{

         VMHost = $esx

         VirtualSwitch = $sw

         PortGroup =  $pg

         VMotionEnabled = $true

         IP = $ip

         SubnetMask = $mask

         Confirm = $false

    }

    New-VMHostNetworkAdapter @sVmk

    Result:

    Get-VirtualSwitch : 7/8/2020 9:22:11 AM    Get-VirtualSwitch        VirtualSwitch with name 'vmk3' was not found using the specified

    filter(s).   

    At line:7 char:7

    + $sw = Get-VirtualSwitch -VMHost $esx -Name $switchName

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

        + CategoryInfo          : ObjectNotFound: (:) [Get-VirtualSwitch], VimException

        + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetVirtualSwitc

       h

    Get-VirtualPortGroup : Cannot validate argument on parameter 'VirtualSwitch'. The argument is null or empty. Provide an argument

    that is not null or empty, and then try the command again.

    At line:8 char:57

    + $pg = Get-VirtualPortGroup -Name $pgName -VirtualSwitch $sw

    +                                                         ~~~

        + CategoryInfo          : InvalidData: (:) [Get-VirtualPortGroup], ParameterBindingValidationException

        + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetVirtualPortGroup

    New-VMHostNetworkAdapter : Cannot bind parameter 'VirtualSwitch'. Cannot convert the "" value of type

    "System.Management.Automation.PSCustomObject" to type "VMware.VimAutomation.ViCore.Types.V1.Host.Networking.VirtualSwitchBase".

    At line:18 char:26

    + New-VMHostNetworkAdapter @sVmk

    +                          ~~~~~

        + CategoryInfo          : InvalidArgument: (:) [New-VMHostNetworkAdapter], ParameterBindingException

        + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewVMHostNetworkAdapt

       er



  • 9.  RE: Set Vmotion IP in VMkernel adapters through powercli

    Posted Jul 08, 2020 09:56 AM

    No, that should be the name of the VirtualSwitch on which the Portgroup is located in which you want to create the vmkernel.

    From your screenshot that would be ESXC1010-MSL-APP-Windows.
    And the portgroup would be ESXC1010-ESX-VMOTION-34



  • 10.  RE: Set Vmotion IP in VMkernel adapters through powercli

    Posted Jul 08, 2020 10:02 AM

    Yes it actually worked after mentioning as per your comment. Thank you so much for the help.