From 86ebda35d44034569097f3e940bd2d31fab7ce02 Mon Sep 17 00:00:00 2001 From: mycloudrevolution Date: Sun, 19 Feb 2017 11:52:43 +0100 Subject: [PATCH] added function Get-NICDetails --- Modules/Get-NICDetails.psm1 | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Modules/Get-NICDetails.psm1 diff --git a/Modules/Get-NICDetails.psm1 b/Modules/Get-NICDetails.psm1 new file mode 100644 index 0000000..30f1440 --- /dev/null +++ b/Modules/Get-NICDetails.psm1 @@ -0,0 +1,93 @@ +function Get-NICDetails { +<# + .NOTES + =========================================================================== + Created by: Markus Kraus + Twitter: @VMarkus_K + Private Blog: mycloudrevolution.com + =========================================================================== + Changelog: + 2017.02 ver 1.0 Base Release + =========================================================================== + External Code Sources: + - + =========================================================================== + Tested Against Environment: + vSphere Version: ESXi 6.0 U2, ESXi 6.5 + PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 + PowerShell Version: 4.0, 5.0 + OS Version: Windows 8.1, Server 2008 R2, Server 2012 R2 + Keyword: ESXi, NIC, vmnic, Driver, Firmware + =========================================================================== + + .DESCRIPTION + Reports Firmware and Driver Details for your ESXi vmnics. + + .Example + Get-NICDetails -Clustername * + + .PARAMETER Clustername + Name or Wildcard of your vSphere Cluster Name to process. + + +#Requires PS -Version 4.0 +#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} +#> + +[CmdletBinding()] +param( + [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] + [ValidateNotNullorEmpty()] + [String] $Clustername + +) + +Begin { + $Validate = $True + + if (($myCluster = Get-Cluster -Name $Clustername).count -lt 1) { + $Validate = $False + thow "No Cluster '$myCluster' found!" + } + +} + +Process { + + $MyView = @() + if ($Validate -eq $True) { + + foreach ($myVMhost in ($myCluster | Get-VMHost)) { + + $esxcli2 = Get-ESXCLI -VMHost $myVMhost -V2 + $niclist = $esxcli2.network.nic.list.invoke() + + $nicdetails = @() + foreach ($nic in $niclist) { + + $args = $esxcli2.network.nic.get.createargs() + $args.nicname = $nic.name + $nicdetail = $esxcli2.network.nic.get.Invoke($args) + $nicdetails += $nicdetail + + } + ForEach ($nicdetail in $nicdetails){ + $NICReport = [PSCustomObject] @{ + Host = $myVMhost.Name + vmnic = $nicdetail.Name + LinkStatus = $nicdetail.LinkStatus + BusInfo = $nicdetail.driverinfo.BusInfo + Driver = $nicdetail.driverinfo.Driver + FirmwareVersion = $nicdetail.driverinfo.FirmwareVersion + DriverVersion = $nicdetail.driverinfo.Version + } + $MyView += $NICReport + } + + } + + $MyView + + } +} +} \ No newline at end of file