Check for automatic checkpoint support before configuring
The AutomaticCheckpointsEnabled option may not always be available depending on the version in use. Check for support before applying the configured value. If automatic checkpoints are to be enabled and support is not available, force an error.
This commit is contained in:
parent
7a7ae59704
commit
1f74aedeaa
|
@ -106,6 +106,11 @@ if($EnableAutomaticCheckpoints) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if($autochecks -eq 1 -and (Get-Command Hyper-V\Set-VM).Parameters["AutomaticCheckpointsEnabled"] -eq $null) {
|
||||||
|
Write-ErrorMessage "AutomaticCheckpointsEnabled is not available"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
Hyper-V\Set-VM -VM $VM -AutomaticCheckpointsEnabled $autochecks
|
Hyper-V\Set-VM -VM $VM -AutomaticCheckpointsEnabled $autochecks
|
||||||
} catch {
|
} catch {
|
||||||
Write-ErrorMessage "Failed to ${AutoAction} automatic checkpoints on VM: ${PSItem}"
|
Write-ErrorMessage "Failed to ${AutoAction} automatic checkpoints on VM: ${PSItem}"
|
||||||
|
|
Loading…
Reference in New Issue