forked from jasemccarty/Vsan-Settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VsanSetFakeSCSIReservations.ps1
36 lines (30 loc) · 1.54 KB
/
VsanSetFakeSCSIReservations.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
[CmdletBinding()]Param(
[Parameter(Mandatory=$true)][String]$Cluster,
[Parameter(Mandatory=$true)][Boolean]$Enable
)
# Get the Cluster Object
$VsanCluster = Get-Cluster -Name $Cluster
# Enumerate all the hosts in the cluster & determine if FakeSCSIReservations are enabled/not based on the input
Foreach ($VMhost in ($VsanCluster | Get-VMHost | Sort-Object Name )) {
# Retrieve the current setting for Fake SCSI Reservations
$CurrentFakeSCSISetting = Get-AdvancedSetting -Entity $VMhost -Name "VSAN.FakeSCSIReservations"
# If the current value differs from the $Enabled parameter then change the state
Switch ($CurrentFakeSCSISetting.Value){
"0" {
If ($Enable -eq $true) {
Write-Host "Enabling 'Fake SCSI Reservations' for vSAN on" $VMhost.Name
Get-AdvancedSetting -Entity $VMHost -Name "VSAN.FakeSCSIReservations" | Set-AdvancedSetting -Value "1" -Confirm:$False
} else {
Write-Host "'Fake SCSI Reservations' for vSAN already disabled on"$VMHost.Name
}
}
"1" {
If ($Enable -eq $false) {
Write-Host "Disabling 'Fake SCSI Reservations' for vSAN on" $VMhost.Name
Get-AdvancedSetting -Entity $VMHost -Name "VSAN.FakeSCSIReservations" | Set-AdvancedSetting -Value "0" -Confirm:$False
} else {
Write-Host "'Fake SCSI Reservations' for vSAN already enabled on"$VMHost.Name
}
}
}
}