Virtu-Al.Net

Virtually everything is poshable

Getting VMware Host Physical Nic Speeds

I had an issue with one of my hosts this week who’s nic had auto-negotiated to the wrong speed, following this I wrote a quick script to check the rest of my hosts.

Good job as there were a fair few nics running at 100MB rather than 1GB causing a few issues.

The following script will list each host and there nics and speeds….

Connect-VIServer MYVISERVER

$VMhosts = Get-VMHost | Get-View
Foreach ($vmhost in $vmhosts){
	Write-Output $vmhost.Name
	$pnic = 0
	Do {
		$Speed = $VMhost.Config.Network.Pnic[$pnic].LinkSpeed.SpeedMb
		Write "Pnic$pnic $Speed"
		$pnic ++
	} Until ($pnic -eq ($VMhost.Config.Network.Pnic.Length))}

4 Responses to “Getting VMware Host Physical Nic Speeds”

  • Iri says:

    Very useful, thanks.

  • Virtu-Al says:

    Thanks Iri, Glad someone else finds it usefull.

  • Eugene says:

    I’m kind of new to the powershell scripts so maybe I’m missing something simple. To run this would I just paste it into a notepad and save with a .ps1 extension then run it? If so I’m getting an error that says:

    [vSphere PowerCLI] C:\Powershell_Scripts> .\GetHostPhysicalNicSpeed.ps1
    Unexpected token ‘in’ in expression or statement.
    At C:\Powershell_Scripts\GetHostPhysicalNicSpeed.ps1:3 char:52
    + $VMhosts = Get-VMHost | Get-ViewForeach ($vmhost in <<<< $vmhosts){Write-Out
    put
    + CategoryInfo : ParserError: (in:String) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

  • Virtu-Al says:

    Sorry had an issue with the code when it was pasted to the blog, try it again now.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>