Thanks very much again, it works as it's changing the value, but it doesnt set it to 9000. And for the hosts that I had manually changed it to 9000, it went and put it back to 1500.
That's what I am running.
$tgtMtuSize = 9000
foreach($dvSw in (Get-VirtualSwitch -Distributed -VMHost (Get-Cluster -Name Cluster01 | Get-VMHost))){
$dvSw.ExtensionData.Config.Host | %{
$esx = Get-View $_.Config.Host
foreach($pnic in $_.Config.Backing.PnicSpec){
$netSys = Get-View $esx.configManager.networkSystem
foreach($vnic in $netSys.NetworkConfig.Vnic | where {$_.Spec.DistributedVirtualPort}){
$spec = [VMware.Vim.HostVirtualNicSpec]$vnic.spec
$spec.mtu = $MTUSize
$netSys.UpdateVirtualNic($vnic.Device,$spec)
}
}
}
}
Edit: Oh.. the $spec.mtu = looks for the $MTUSize but the variable has been set to $tgtMtuSize, that's what I suppose is the problem?
Editno2: Yes that it, thanks very much!