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!
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
Hey,
try it with this:
Get-VMHostNetworkAdapter | ?{$_.Name -match "vmnic"} | Select vmhost,Name,BitRatePerSec,FullDuplex | Export-Csv c:\temp\vmnic.csv
Tim
Not sure where it is not working but there is no output file?
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.
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!!
Sure,
you could filter the output more with something like | ? {$_.BitRatePerSec -ne "0" }
And perform a "disconnect-viserver" after
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 😕
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