SHIFT

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

User Tools

Site Tools


powercligethostnetworkinfo
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

powercligethostnetworkinfo [2013/04/20 13:33] (current)
sjoerd created
Line 1: Line 1:
 += 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
 +
 +<code powershell>​
 +# 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
 +   }
 +}
 +
 +</​code>​
 +
 +{{tag>​scripts vmware}}
powercligethostnetworkinfo.txt ยท Last modified: 2013/04/20 13:33 by sjoerd