# create a snapshot of all running Hyper V machines
$runningVMs = Get-VM | Where-Object { $_.State -eq 'Running' }

foreach ($vm in $runningVMs) {
    $snapName = "$($vm.Name)_$(Get-Date -Format 'yyyyMMdd_HHmm')"
    Checkpoint-VM -Name $vm.Name -SnapshotName $snapName
    Write-Host "Checkpoint created: $snapName"
}
