Thanks very much for your help. Last one is that I am trying to get the Datastore diskspace used by VM so I have tried adding the line below but I guess it it not formatted correctly because when I try to re-format the command it either does not work or it causes script errors?
$info.DatastoreUsed = (Get-HardDisk -VM $vm.name -Property Name | Select-Object CapacityGB).Name -join '|'