User Tools

Site Tools


hyper-v_snapshots

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
hyper-v_snapshots [2023/01/13 01:26] osohyper-v_snapshots [2024/10/17 21:42] (current) – external edit 127.0.0.1
Line 9: Line 9:
 </WRAP> </WRAP>
  
 +===== Get snapshot count for each VM =====
 +
 +To count the number of snapshots/checkpoints for each VM in a Hyper-V host, you can use PowerShell. Here’s a refined version of your script that will do just that:
 +
 +<code powershell>
 +$vms = Get-VM
 +foreach ($vm in $vms) {
 +    $snapshotCount = (Get-VMSnapshot -VMName $vm.Name).Count
 +    Write-Output "$($vm.Name): $snapshotCount"
 +}
 +</code>
 +
 +Explanation:
 +  * Get-VM retrieves all VMs on the host.
 +  * For each VM, ''Get-VMSnapshot'' fetches the snapshots, and ''.Count'' gives the number of snapshots.
 +  * Finally, it outputs the VM name along with its snapshot count.
hyper-v_snapshots.1673573181.txt.gz · Last modified: 2024/10/17 21:42 (external edit)