Wrap automatic checkpoint enable to prevent inadvertent execution

This commit is contained in:
Chris Roberts 2018-10-04 15:16:58 -07:00
parent a4231d630a
commit 9c1ab2bd9f
1 changed files with 7 additions and 5 deletions

View File

@ -106,12 +106,14 @@ if($EnableAutomaticCheckpoints) {
}
try {
if($autochecks -eq 1 -and (Get-Command Hyper-V\Set-VM).Parameters["AutomaticCheckpointsEnabled"] -eq $null) {
if((Get-Command Hyper-V\Set-VM).Parameters["AutomaticCheckpointsEnabled"] -eq $null) {
if($autochecks -eq 1) {
Write-ErrorMessage "AutomaticCheckpointsEnabled is not available"
exit 1
}
} else {
Hyper-V\Set-VM -VM $VM -AutomaticCheckpointsEnabled $autochecks
}
} catch {
Write-ErrorMessage "Failed to ${AutoAction} automatic checkpoints on VM: ${PSItem}"
exit 1