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
50
51
52
53
54
55
|
param (
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.ClusterImpl[]]$clusters = $(throw "A list of clusters must be specified."),
[switch]$all
)
# A hash table to keep track of what we have seen.
$lunMap = @{}
# Get all of the LUNs and the clusters they are on
foreach ($cluster in $clusters) {
Write-Host "." -NoNewline
foreach ($vmhost in Get-VMHost -Location $cluster) {
foreach ($lun in (Get-ScsiLun -VmHost $vmhost)) {
$id = $lun.ExtensionData.Uuid
if ($lunMap.containsKey($id)) {
if (! ($lunMap[$id].Clusters -contains $cluster.Name)) {
# Update the cluster list
$lunMap[$id].Clusters += $cluster.Name
}
}
else {
# Create an entry for this LUN
$info = "" | Select-Object CanonicalName, Clusters
$info.Clusters = @($cluster.Name)
$info.CanonicalName = $lun.CanonicalName
$lunMap[$id] = $info
}
}
}
}
# Output the ones we care about
foreach ($key in $lunMap.Keys) {
if (($lunMap[$key].Clusters.length -gt 1) -or $all) {
"" | Select-Object @{Name="ScsiLunUuid"; Expression={$key}}, @{Name="CanonicalName"; Expression={$lunMap[$key].CanonicalName}},
@{Name="Clusters"; Expression={$lunMap[$key].Clusters}}
}
}
<#
.SYNOPSIS
Find the LUNs that are shared by clusters.
.PARAMETER clusters
An array of the clusters you want to check. The script is generally only
useful with 2 or more clusters.
.PARAMETER all
Output all of the LUN -> cluster details instead of just the duplicates
.EXAMPLE
.\Get-DuplicatePresentation (Get-Cluster)
.EXAMPLE
.\Get-DuplicatePresentation (Get-Cluster cluster1,cluster2)
#>
|