From ea866993dfba819821e113610bd5d01a88f982a9 Mon Sep 17 00:00:00 2001 From: mycloudrevolution Date: Mon, 1 Aug 2016 23:04:48 +0200 Subject: [PATCH] Report-LUNPath-ESXCLI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This script will create a Report of LUNs with Paths that have more than one unique LUN ID or have more than the defined Paths. Information’s will be gathered via ESXCLI. This is necessary to report also hidden Paths! --- Scripts/Report-LUNPath-ESXCLI.ps1 | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Scripts/Report-LUNPath-ESXCLI.ps1 diff --git a/Scripts/Report-LUNPath-ESXCLI.ps1 b/Scripts/Report-LUNPath-ESXCLI.ps1 new file mode 100644 index 0000000..7d9fa79 --- /dev/null +++ b/Scripts/Report-LUNPath-ESXCLI.ps1 @@ -0,0 +1,50 @@ +<# + .NOTES + =========================================================================== + Created by: Markus Kraus + Organization: Private + Personal Blog: mycloudrevolution.com + Twitter: @vMarkus_K + =========================================================================== + .DESCRIPTION + This script will create a Report of LUNs with Paths that have more than one unique LUN ID or have more than the defined Paths. + Information’s will be gathered via ESXCLI. This is necessary to report also hidden Paths! + + .Example + ./Report-LUNPath-ESXCLI.ps1 + +#> + +#region 1: Global Definitions +$MaxLUNPaths = 2 +#endregion + +#region 2: Get all Connected Hosts +$myHosts = Get-VMHost | where {$_.ConnectionState -eq "Connected" -and $_.PowerState -eq "PoweredOn"} +#endregion + +#region 3: Create Report +$Report = @() +foreach ($myHost in $myHosts) { + $esxcli2 = Get-ESXCLI -VMHost $myHost -V2 + $devices = $esxcli2.storage.core.path.list.invoke() | select Device -Unique + + foreach ($device in $devices) { + $arguments = $esxcli2.storage.core.path.list.CreateArgs() + $arguments.device = $device.Device + $LUNs = $esxcli2.storage.core.path.list.Invoke($arguments) + + $LUNReport = [PSCustomObject] @{ + HostName = $myHost.Name + Device = $device.Device + LUNPaths = $LUNs.Length + LUNIDs = $LUNs.LUN | Select-Object -Unique + } + $Report += $LUNReport + } + } +#endregion + +#region 4: Output Report +$Report | where {$_.LUNPaths -gt $MaxLUNPaths -or ($_.LUNIDs | measure).count -gt 1 } | ft -AutoSize +#endregion \ No newline at end of file