-
Notifications
You must be signed in to change notification settings - Fork 484
/
VMKLinuxDrivers.ps1
49 lines (45 loc) · 1.8 KB
/
VMKLinuxDrivers.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Function Get-VMKLinuxDrivers {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.williamlam.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function returns the list of ESXi hosts within a vSphere Cluster
that is currently has VMklinux Drivers in use and the list of drivers
.PARAMETER Cluster
The name of a vSphere Cluster to analyze
.EXAMPLE
Get-VMKLinuxDrivers -Cluster Cluster-01
#>
param (
[Parameter(Mandatory=$true)][string]$Cluster
)
$vmhosts = Get-Cluster $Cluster | Get-VMHost | where {$_.ConnectionState -eq "Connected"}
$results = @()
foreach ($vmhost in $vmhosts | Sort-Object -Property name) {
Write-Host "Checking $($vmhost.name) ..."
$esxcli = Get-EsxCli -VMHost $vmhost -V2
$modules = $esxcli.system.module.list.Invoke() | where {$_.IsLoaded -eq $true}
$vmklinuxDrivers = @()
foreach ($module in $modules) {
$moduleName = $esxcli.system.module.get.CreateArgs()
$moduleName.module = $module.name
$vmkernelModule = $esxcli.system.module.get.Invoke($moduleName)
if($vmkernelModule.RequiredNamespaces -match "com.vmware.driverAPI") {
$vmklinuxDrivers += $module.name
}
}
if($vmklinuxDrivers -ne $null) {
$tmp = [pscustomobject] @{
VMHost = $vmhost.name;
VMKLinuxDriver = ($vmklinuxDrivers -join ",")
}
$results += $tmp
}
}
$results | Sort-Object -Property VMHost | FT
}