VMware Cloud Community
Guv
Enthusiast
Enthusiast
Jump to solution

Powershell commands for esxcfg commands on esx

I am running some esxcfg commands on my ESX 4 servers to create a vswitch and vmkernel ports with a mtu value of 9000 (jumbo frames), but i would rather run these commands in powershell equivalent. The esxcfg commands are:

creating a new vswitch called vswitchA:

esxcfg-vswitch -a vSwitchA

Then, set the MTU of the vSwitch.

esxcfg-vswitch -m 9000 vSwitchA

list all the vSwitches so you can confirm your changes and settings

esxcfg-vswitch -l

create the portgroup port1

esxcfg-vswitch -A port1 vSwitch9

Then create the VMkernel interface with IP and mtu value.

esxcfg-vmknic -a -i 172.16.0.1 -n 255.255.255.0 -m 9000 iSCSI

will confirm your settings.

esxcfg-vmknic -l

Can anyone advise in getting the powershell commands for the above esxcfg commands

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Only the portgroup, but you can use the Set-VirtualSwitch cmdlet which also has a -MTU parameter.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

IN PowerCLI 4.1 you can specify the MTU with the New-VMHostNetworkAdapter cmdlet.

Something like this will do the same as the esxcfg- commands you used.

$esxName = <hostname>
$vSwitchName = "vSwitch9"
$pgName = "port1"

$esx = Get-VMHost -Name $esxName

# Create the virtual switch
$sw = New-VirtualSwitch -Name $vSwitchName -VMHost $esx

# Create the portgroup
New-VirtualPortGroup -VirtualSwitch $sw -Name $pgName 

# Set the portgroup up as a VMkernel with an MTU of 9000
New-VMHostNetworkAdapter -ConsoleNic:$false -VirtualSwitch $sw `
	-VMHost $esx -PortGroup $pgName -Mtu 9000 -IP 72.16.0.1 -SubnetMask 255.255.255.0

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Guv
Enthusiast
Enthusiast
Jump to solution

Does the above script change the mtu value of the new vswitch, as it seems to only change the mtu value of the new vmkernal port only.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Only the portgroup, but you can use the Set-VirtualSwitch cmdlet which also has a -MTU parameter.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos