Automation

 View Only
  • 1.  How to change NIC settings with Set-VMHostNetworkAdapter

    Posted Aug 22, 2008 05:56 PM

    How do I use Set-VMHostNetworkAdapter to set the link speed and duplex mode of a give NIC of a server?

    This doesn't work:

    $myhost | Set-VMHostNetworkAdapter -PhysicalNic vmnic0 -Duplex "Full" -BitRatePerSecMb 100



  • 2.  RE: How to change NIC settings with Set-VMHostNetworkAdapter

    Posted Aug 22, 2008 06:20 PM

    Wow the Beattles are into Powershell? I got this from a colleage when working through my new ESXi config scripts.

    $physnics = get-vmhost <vmhost> | get-vmhostnetwork | % {$_.Physicalnic}

    set-vmhostnetworkadapter -PhysicalNic $physnics -BitRatePerSecMB <bitrate> -Duplex <duplex>

    I then sleep for 5 seconds with

    start-sleep -s 5

    then send a reconnect - if you're doing all nics, you'll be doing the NIC that your attaching to for running the script. Some environments flip duplex quicker so you may have to adjust the seconds.

    Message was edited by: olan025

    To do a specific one... Add this following the first line starting with the pipe........... | where { $_.DeviceName -like "vmnic0"}

    $physnics= get-vmhost <vmhost> | get-vmhostnetwork | %{$_.physicalnic}| where { $_.DeviceName -like "vmnic0"}

    set-vmhostnetworkadapter -PhysicalNic $physnics -BitRatePerSecMB 1000 -Duplex full



  • 3.  RE: How to change NIC settings with Set-VMHostNetworkAdapter

    Posted Aug 22, 2008 06:27 PM

    That cmdlet only works when you are connected to an ESX server.

    So first do

    Connect-VIServer -Server <ESX-server> -User <account> -Password <password>
    

    You should notice that the variable $DefaultVIServer now contains the ESX server to which you just connected.

    The Set-VMHostNetworkAdapter cmdlet expects an object of the type VMware.VimAutomation.Types.Host.NIC.PhysicalNic with the -PhysicalNic parameter.

    You can get at these with the following

    Get-VMHostNetwork | Select PhysicalNic
    

    And now, finallly, you use the Set-VMHostNetworkAdapter cmdlet to change link speed and duplex mode

    Get-VMHostNetwork | Select PhysicalNic | Set-VMHostNetworkAdapter -Duplex "Full" -BitRatePerSecMb 100
    



  • 4.  RE: How to change NIC settings with Set-VMHostNetworkAdapter

    Posted Aug 22, 2008 06:39 PM

    thank you both for the quick answer. Is it possible to select which NICs to operate on? There is one I don't need to update, the rest I do.



  • 5.  RE: How to change NIC settings with Set-VMHostNetworkAdapter
    Best Answer

    Posted Aug 22, 2008 06:42 PM

    Insert a Where-Object in the pipe and you could filter for example on the physical NIC name.



  • 6.  RE: How to change NIC settings with Set-VMHostNetworkAdapter

    Posted Feb 22, 2014 12:59 PM

    Thanks guys, i will check this