LucDJosh26ctech930DaryllKrisVMware {code}
Is it possible to set the vmotion IP in vmkernel adapters for esxi host through powercli ?
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.
$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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do something like this
where{$_.VMotionEnabled} |
Set-VMHostNetworkAdapter -IP 192.168.1.11 -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm not sure anymore what you actually want to do.
Are you creating a new vmkernel or adapting an existing one?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yeah creating a new vmkernel and point it to existing vmotion network for the cluster.
This is what I'm talking about.
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.
$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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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
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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes it actually worked after mentioning as per your comment. Thank you so much for the help.