SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


Sidebar

Recently Changed Pages:

View All Pages


View All Tags


LinkedIn




WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you.
Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer.


Pages with comments

View All Comments

powercligethostnetworkinfo

Script: PowerCLI: Get Host Network Information

This script will grab all network information from a host including:

  • vmnic configuration
  • vmkernel ports information
  • service console information
  • all virtual switches
  • all port groups
# Basehost must be an exact match to the name in vcenter
$BASEHost = Read-Host "Enter the name of the server as found in vCenter"
 
$timestamp = Get-Date -format "yyyyMMdd-HH.mm"
$outfile = "D:\sjoerd\$timestamp-$basehost-networkinfo.txt"
 
$timestamp | Out-File $outfile
 
# Original command:
# Get-VMHostNetwork $BASEHost | Select HostName,Domain,ConsoleGateWay,DnsAddress
Add-Content $outfile "`nFinding VMkernel and Service Console information on $BASEHost" -Encoding unicode
Get-VMHostNetwork $BASEHost | Format-List | Out-File $outfile -width 500 -append
 
# Original command:
# Get-VMHostNetworkAdapter $BASEHost | select VMhost, Name, IP, SubnetMask, Mac, PortGroupName, vMotionEnabled, mtu, FullDuplex, BitRatePerSec
# Get-VMHostNetworkAdapter $BASEHost | select VMhost, Name, IP, SubnetMask, Mac, PortGroupName, vMotionEnabled, mtu, FullDuplex, BitRatePerSec | Export-Csv $csvfilenic
Add-Content $outfile "`nListing all NIC information on $BASEHost" -Encoding unicode
Get-VMHostNetworkAdapter $BASEHost | select VMhost, Name, IP, SubnetMask, Mac, PortGroupName, vMotionEnabled, mtu, FullDuplex, DHCPEnabled, BitRatePerSec | Out-File $outfile -width 500 -append
 
Get-VirtualSwitch $BASEHost |Foreach {
   $switch = $_.Name
   $numports = $_.NumPorts
   $mtu = $_.Mtu
   Add-Content $outfile "`nSwitch $switch on $BASEHost has $numports number of ports and has a configured mtu size of $mtu" -Encoding unicode
   $_ |Get-VirtualPortGroup |Foreach {
   $portgroup = $_.Name
   $vlan = $_.VlanID
   Add-Content $outfile "`nPortgroup $portgroup has vlanid $vlan" -Encoding unicode
   }
}
You could leave a comment if you were logged in.
powercligethostnetworkinfo.txt · Last modified: 2021/09/24 00:25 (external edit)