VMware Cloud Community
pamiller21
Enthusiast
Enthusiast
Jump to solution

Script to check speed and duplex

Hey all,

I have been looking and trying to find a script to export to a csv file a simple sheet showing the speeds and duplex of all the physical NICs in our environment.  Any advice would be greatly appreciated!

0 Kudos
1 Solution

Accepted Solutions
schepp
Leadership
Leadership
Jump to solution

Get-VMHostNetworkAdapter | ?{$_.Name -match "vmnic" -and $_.BitRatePerSec -ne "0"} | Select vmhost,Name,BitRatePerSec,FullDuplex | Export-CSV -Path "C:\PowerCLI Scripts\Reports\VMNICs.csv" -NoTypeInformation -UseCulture

The above should work. Have no PowerCLI on my phone to test it though Smiley Wink

View solution in original post

0 Kudos
7 Replies
schepp
Leadership
Leadership
Jump to solution

Hey,

try it with this:

Get-VMHostNetworkAdapter | ?{$_.Name -match "vmnic"} | Select vmhost,Name,BitRatePerSec,FullDuplex | Export-Csv c:\temp\vmnic.csv

Tim

0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

Not sure where it is not working but there is no output file?

0 Kudos
schepp
Leadership
Leadership
Jump to solution

Have you tried another directory? Like your desktop? Maybe a permission problem.

Also try to run it without the "| Export-Csv ...." part, so you get the output in the shell.

0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

Found the error, it was in the dir I was sending it to. This is a fantastic start, is there anyway to remove any nics that have a speed of 0? 

Also is there a command to disconnect the user that connects and runs these scripts.  I am noticing the user reconnects and leaves an open session after ever run I'm doing?

Thanks again!!

0 Kudos
schepp
Leadership
Leadership
Jump to solution

Sure,

you could filter the output more with something like | ? {$_.BitRatePerSec -ne "0" }

And perform a "disconnect-viserver" after

0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

I got the disconnect to work with some additional work, here is what I have:

Get-VMHostNetworkAdapter | ?{$_.Name -match "vmnic"} | Select vmhost,Name,| ? {$_.BitRatePerSec -ne "0" },FullDuplex disconnect-viserver  |

Export-CSV -Path "C:\PowerCLI Scripts\Reports\VMNICs.csv" -NoTypeInformation -UseCulture

Disconnect-VIServer 127.0.0.1 -Confirm:$false

The filter isnt working 😕

0 Kudos
schepp
Leadership
Leadership
Jump to solution

Get-VMHostNetworkAdapter | ?{$_.Name -match "vmnic" -and $_.BitRatePerSec -ne "0"} | Select vmhost,Name,BitRatePerSec,FullDuplex | Export-CSV -Path "C:\PowerCLI Scripts\Reports\VMNICs.csv" -NoTypeInformation -UseCulture

The above should work. Have no PowerCLI on my phone to test it though Smiley Wink

0 Kudos