Share via


Simple SCVMM Script to enable Jumbo Frame on all your Hyper-V hosts

Fortunaly, i use SCVMM, and SCVMM know everything about all my Hyper-V servers :)

This simple script will help you to configure the MTU value on all the host inside a cluster.

To prevent outage, each host is put in maintenance mode before modifying the configuration.

To use it, you have to provide the following parameters

  • The ClusterName
  • The MTU Size (Depending of your Nic vendor, generaly 9014 or 1514)
  • The interface alias (you can provide only the begining of the name)
  • The VMMServer (Optionnal if you are localy on the VMM Server)

This script is provided "as is" as an exemple of what you can achieve with Powershell and VMM, use it at your own risk.

Beware before using it on a production site, this script can cause interruption of service.

 

Param($ClusterNAme, $MTUSize, $NetAdapterAlias, $VMMServerName)

If($VMMServerName -eq $Null){$VMMServerName = "LocalHost"}

$VMMServer = Get-ScVMMServer -computername $VMMServerName

Get-ScvmHostCluster $ClusterName|%{

$_.nodes |%{

$VMhostName = $_.name

Write-host "Enter Node $VmHostName" -ForegroundColor Yellow

Write-host "**********************************************" -ForegroundColor Yellow

$Session = New-PSSession -ComputerName $VmHostName

Invoke-Command -Session $Session -Argumentlist $MTUSize, $NetAdapterAlias -scriptblock {

Param($MTUSize, $NetAdapterAlias)

Write-host "Actual MTU Value Is :"

get-netadapter |?{$_.Name -like $NetadapterAlias+"*"}|Get-NetAdapterAdvancedProperty -RegistryKeyword "*JumboPacket" |ft InterfaceAlias, DisplayValue

Write-host "Putting Host in Maintenance Mode"

$disable = (Disable-ScVmHost $VmHostName -MoveWithinCluster)

If ($VmHostName.OverallState -eq "MaintenanceMode"){

Write-host "$VmHostName is in Maintenance Mode"

}Else{

Write-host "Maintenance Mode Failed exiting"

Exit

}

get-netadapter |?{$_.Name -like $NetadapterAlias+"*"}|Set-NetAdapterAdvancedProperty -RegistryKeyword "*JumboPacket" -DisplayValue $MTUSize

Write-host "New MTU Value Is :"

get-netadapter |?{$_.Name -like $NetadapterAlias+"*"}|Get-NetAdapterAdvancedProperty -RegistryKeyword "*JumboPacket" |ft InterfaceAlias, DisplayValue

$enable = (Enable-ScVmHost $Node)

If ($Node.OverallState -eq "OK"){

Write-host "$vmHostName is now Up"

}Else{

Write-host "$VmHostName fail to exit Maintenance Mode, Check configuration..."

Quit

}

}

Remove-PSSession -Session $Session

}

}