I am currently writing a program in C#, which automatizes the control of Virtual Machines, that are stored on a central server. At the Moment I am working on a function to create "Snapshots", images of the Virtual Machine, to which this Virtual Machine can be reset to.
The problem is, that I need to know the size of the VM, (or the space that it is taken), but with Powershell this doesn't work the way I used for other actions.
I have now created this Powershell command to get the size of VMs:
Invoke-Command -ComputerName Jack -ScriptBlock {Get-VM -VMName Sisi | gci -r -Filter *.avhd*| select name, @{Name="MB";Expression={$_.Length / 1Mb}}
But I still get a list of all the images that are made from the called VM. I want to work it like this one I used to get Informations, that are in the Informations from the Snapshot itself.
Invoke-Command -ComputerName Jack -ScriptBlock {Get-VMSnapshot –VMName Sisi -Name Attemt |Select-Object -Property CreationTime, Name}
Is there a way to get the names and creation times together with the size of the Snapshots?
Thanks for the answers in advance.
Edit:
I just found out I can add , CreationTime
, it seems like I misspelled it the first time, still the name of the Snapshot isn't accessible directly, and I don't know any workaround.
Edit: Creation Time of the Image and the Imagefile differ a view seconds which makes the use of Creation time to find the File of the Snapshot for the Snapshot very ineffective, so getting the name of the Snapshot itself out of the Snapshotfile is even more important and I still don't know how.