Tuesday, September 1, 2015

VMware PowerCLI export ova

#Set ENV
$VM = Get-Content .\vmhost_list.txt
$BackupvCenter = "vCenter.domain.local"
$BackupHost = "esxi-01.Domain.local"
$backupDate = Get-Date -Format yyyyMMdd
$backupDatastore = "vmd-01:LocalStorage"

Connect-VIServer -Server $BackupvCenter -User user_name@domain.local -Password user_password

#Dynamically create a folder
$BackupDir = "E:\vMware-backup\$BackupDate"
mkdir $BackupDir

foreach ($line in $VM) {

    Get-VM -Server $BackupvCenter  | where { $_.PowerState -like 'PoweredOn' -and $_.name -like $line } | select name, vmhost, usedspacegb

    $VM_TMP = $line+'-ova_backup-'+$backupDate

#Clone New VM
New-VM -Name $VM_TMP -VM $line -VMHost $BackupHost -Datastore $backupDatastore

#Export OVA file
Export-VApp -Destination $BackupDir -VM $VM_TMP -Format OVA

#Remove-VM $TMP -DeleteFromDisk -Confirm:$true
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

ALCATEL 6900

write memory copy running certified reload from working no rollback-timeout