How would i go about getting this? The -Property of this command doesn't contain a option or attribute for getting this?
Like this
Get-VM -PipelineVariable vm | Get-Snapshot -PipelineVariable snap |
select @{N='VM';E={$vm.Name}},Name,SizeMB,Created,
@{N='VMSN';E={($vm.ExtensionData.Layout.Snapshot | where{$_.Key -eq $snap.ExtensionData.Snapshot}).SnapShotFile | where{$_ -match ".vmsn$"}}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
$vmName = 'MyVM'
$snapName = 'MySnap'
$vm = Get-VM -Name $vmName
$snap = Get-Snapshot -VM $vm -Name $snapName
($vm.ExtensionData.Layout.Snapshot | where{$_.Key -eq $snap.ExtensionData.Snapshot}).SnapShotFile | where{$_ -match ".vmsn$"}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
How would I pull the VM and the Snapshot name automatically? So in others words. If I am connected to a vCenter, how would I pull all Snapshots with the file location. So in the below command how would i add the file location attribute? This command gets snapshots, I do not have to enter the snapshot name or VM name, once connected to the vCenter.
get-vm | get-snapshot | Select-Object -Property vm,created,sizeGB,name,description | Export-Csv -Path C:\Users\$env:username\Desktop\snapshots.csv
Try like this
Get-VM -PipelineVariable vm | Get-Snapshot -PipelineVariable snap |
select @{N='VM';E={$vm.Name}},Name,
@{N='VMSN';E={($vm.ExtensionData.Layout.Snapshot | where{$_.Key -eq $snap.ExtensionData.Snapshot}).SnapShotFile | where{$_ -match ".vmsn$"}}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
How would i also include the size, date and time of the file into your script?
Like this
Get-VM -PipelineVariable vm | Get-Snapshot -PipelineVariable snap |
select @{N='VM';E={$vm.Name}},Name,SizeMB,Created,
@{N='VMSN';E={($vm.ExtensionData.Layout.Snapshot | where{$_.Key -eq $snap.ExtensionData.Snapshot}).SnapShotFile | where{$_ -match ".vmsn$"}}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference