$username = "username@vsphere.local"
$viServer = "servername"
$passwd = "pass"
$dstfolder = "C:\Image"
Connect-VIServer -Server $ViServer -User $username -Password $passwd
$vms = Get-VM | where {$_.name -like "*_vms"}
echo $vms.name
foreach ($vm in $vms){
echo $vm.Name,$dstfolder
Export-VM -VM $vm -Destination $dstfolder -CreateSeparateFolder -Format Ovf 2>&1 > $dstfolder\$vm.txt
}