forked from jasemccarty/Vsan-Settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vsan-SetDedupeScan.ps1
94 lines (76 loc) · 2.63 KB
/
Vsan-SetDedupeScan.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<#==========================================================================
Script Name: Vsan-SetDedupeScan.ps1
Created on: 7/18/2016
Created by: Jase McCarty
Github: http://www.github.com/jasemccarty
Twitter: @jasemccarty
Website: http://www.jasemccarty.com
===========================================================================
.DESCRIPTION
This script sets advanced settings for DedupeScan on Hybrid Virtual SAN 6.2
Referenced in http://kb.vmware.com/kb/2146267
Syntax is:
To Set DedupeScan On
Vsan-SetDedupeScan.ps1 -ClusterName <ClusterName> -DedupeScan enable
To turn DedupeScan Off
Vsan-SetDedupeScan.ps1 -ClusterName <ClusterName> -DedupeScan disable
.Notes
#>
# Set our Parameters
[CmdletBinding()]Param(
[Parameter(Mandatory=$True)]
[string]$ClusterName,
[Parameter(Mandatory = $true)]
[ValidateSet('enable','disable')]
[String]$DedupeScan
)
# Must be connected to vCenter Server 1st
# Connect-VIServer
# Get the Cluster Name
$Cluster = Get-Cluster -Name $ClusterName
# Check to ensure we have either enable or disable, and set our values/text
Switch ($DedupeScan) {
"disable" {
$DDS = "0"
$DDSTEXT = "Disabled DedupeScan"
}
"enable" {
$DDS = "1"
$DDSTEXT = "Enabed DedupeScan"
}
default {
write-host "Please include the parameter -DedupeScan enable or -DedupeScan disable"
exit
}
}
# Display the Cluster
Write-Host Cluster: $($Cluster.name)
# Cycle through each ESXi Host in the cluster
Foreach ($ESXHost in ($Cluster |Get-VMHost | Sort Name)){
# If the Cluster has VSAN Enabled, then proceed
if ($Cluster.VsanEnabled){
# Grab each disk and check to see if it is SSD or not (Checking for All-Flash)
$HybridDisks = Get-VsanDisk | Where-Object {-Not $_.IsSsd}
# If we find any non-SSD disks, we'll assume a Hybrid Configuration
if ($HybridDisks.count -gt 1) {
Write-Host "Hybrid Architecture: Proceeding"
# Get the current setting for lsomComponentDedupScanType
$DedupeScanType = Get-AdvancedSetting -Entity $ESXHost -Name "LSOM.lsomComponentDedupScanType"
# check to see if the value doesn't match the enable/disable parameter
If($DedupeScanType.value -ne $DDS){
# Show that host is being updated
Write-Host "Updating LSOM DedupeScan Type Setting for $ESXHost"
$DedupeScanType | Set-AdvancedSetting -Value $DDS -Confirm:$false
} else {
# Show that the host is already set for the right Dedupe Scan Type
Write-Host "$ESXHost is already configured for $DDSTEXT"
}
} else {
Write-Host "All-Flash Architecture: Exiting"
Exit
}
} else {
Write-Host "VSAN Not Enabled: Exiting"
Exit
}
}