Skip to content

Instantly share code, notes, and snippets.

@kbni
Last active June 16, 2016 19:06
Show Gist options
  • Save kbni/336ef1aa47c0e2152f64c3790d662a2d to your computer and use it in GitHub Desktop.
Save kbni/336ef1aa47c0e2152f64c3790d662a2d to your computer and use it in GitHub Desktop.
rolling checkpoints? :D
#$VerbosePreference = "Continue"
$SnapShotVM = @("KBNI-TS1", "KBNI-DC1", "KBNI-WWW1")
$LogFile = "C:\Logs\RollingCheckpoints.txt"
$LogDir = New-Item -Type Directory -Path (Split-Path -Path $LogFile)
Foreach($VM in $SnapShotVM) {
$m = Measure-Command { Get-VM $VM | Get-VMSnapshot | Sort-Object -Descending | Select -Skip 24 | Remove-VMSnapshot -Verbose | Out-Host }
$log = [string]::Format("Removing old snapshots for ${VM} took {0:N2} seconds", $m.TotalSeconds)
$log | Out-Host
$log | Out-File -Append -FilePath $LogFile
$m = Measure-Command { Get-VM $VM | Checkpoint-VM -SnapshotName "$(Get-Date) - Automatic Snapshot" -Verbose | Out-Host }
$log = [string]::Format("Creating new snapshot for ${VM} took {0:N2} seconds", $m.TotalSeconds)
$log | Out-Host
$log | Out-File -Append -FilePath $LogFile
}
@kbni
Copy link
Author

kbni commented Jun 16, 2016

This is stupid. D:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment