-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-HyperVSnapshotDisks.psm1
34 lines (28 loc) · 1.08 KB
/
Get-HyperVSnapshotDisks.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function Get-HyperVSnapshotDisks {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[String]$vmName
)
process {
Get-VM -Name $vmName | Get-VMHardDiskDrive | Select-Object @{Name = "Aktuelle `
Festplatte(n)"; Expression = {$_.Path}} | Format-List
foreach ($snapshot in Get-VM -Name $vmName | Get-VMSnapshot) {
$out = new-object psobject;
$out | Add-Member Id ($snapshot.Id);
$out | Add-Member Name ($snapshot.Name);
$out | Add-Member "Erzeugt am" ($snapshot.CreationTime);
$out | Add-Member ParentSnapshotName ($snapshot.ParentSnapshotName);
$out | Add-Member ParentSnapthotId ($snapshot.ParentSnapshotId);
$hardDisk = $snapshot | Get-VMHardDiskDrive
$out | Add-Member Delta-Festplatte ($hardDisk.Path);
$depth = 0
while (![string]::IsNullOrEmpty($snapshot.ParentSnapshotId)) {
$depth = $depth + 1
$snapshot = Get-VMSnapshot -Id $snapshot.ParentSnapshotId
}
$out | Add-Member Hierarchiestufe ($depth);
Write-Output $out | Format-List
}
}
}