Try like this, but not working
Get snaps, names are identical
C:\> Get-VM 17-RDP | Get-Snapshot
Name Description PowerState
---- ----------- ----------
va1 PoweredOff
va1 PoweredOff
Get-VM 17-RDP | Get-Snapshot |
Group-Object -Property {$_.VM.Name},Name -PipelineVariable group
ForEach-Object -Process {
$snapName = "va1"
if($group.Group.Count -ge 1){
$vmName,$snapName = $group.Name.Split(',').Trim(' ')
Get-VM -Name $vmName | Get-Snapshot -Name $snapName |
Remove-Snapshot -Confirm:$false
}
}