-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSet-ConsolidationFix.psm1
58 lines (50 loc) · 3.1 KB
/
Set-ConsolidationFix.psm1
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
Function Set-ConsolidationFix {
<#
.SYNOPSIS
Set VM SnapShot Consolidation Timout Workaround
.DESCRIPTION
Set VM SnapShot Consolidation Timout Workaround
.Example
Set-ConsolidationFix -vCenterVM "myTest" -Fix "Timeout"
.Example
Set-ConsolidationFix -vCenterVM "myTest" -Fix "Stun"
.Notes
NAME: Set-ConsolidationFix.ps1
LASTEDIT: 08/24/2016
VERSION: 1.1
KEYWORDS: VMware, vSphere, ESXi, Workaround, Snapshot
.Link
http://mycloudrevolution.com/
#Requires PS -Version 4.0
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"}
#>
[cmdletbinding()]
param (
[parameter(Mandatory=$true)]
[string]$vCenterVM,
[parameter(Mandatory=$true)]
[string]$Fix = "Timeout" # Timeout os Stun
)
Process {
if (Get-VM $vCenterVM -ErrorAction SilentlyContinue) {
if ($Fix -like "Timeout") {
$myVM = Get-VM $vCenterVM
$MyVM | New-AdvancedSetting -Name snapshot.asyncConsolidate.forceSync -Value TRUE -Confirm:$False -Force:$True
$MySnap = $MyVM | New-Snapshot -Name "ConsolidationFix"
$MySnap | Remove-Snapshot -confirm:$false
}
elseif ($Fix -like "Stun") {
$myVM = Get-VM $vCenterVM
$MyVM | New-AdvancedSetting -Name snapshot.maxConsolidateTime -Value 30 -Confirm:$False -Force:$True
$MySnap = $MyVM | New-Snapshot -Name "ConsolidationFix"
$MySnap | Remove-Snapshot -confirm:$false
}
else {
Write-Error "No Valid Fix"
}
}
else {
Write-Error "VM not Found"
}
}
}