################### Config ##################################
$SourceVC = “vcenter.wardvissers.nl
################## PASSWORD STORE #########################
#Username
# Check if credentials exist in credential store if not ask for credentials and put them in credential store
If ((Get-VICredentialStoreItem).host -notcontains $SourceVC) {New-VICredentialStoreItem -Host $SourceVC -User $env:USERNAME -Password ((get-credential).GetNetworkCredential().Password)}
# Remove-VICredentialStoreItem * -Confirm:$false
#################### END INIT ####################################
#Login to vCenter servers
if (($global:DefaultVIServers).Name -notcontains $SourceVC) {
#SourceVC
$ConnectVC = Connect-VIServer $SourceVC
# Get-Cluster –Name $DestinationCluster –Server $DestinationVC | Get-VMhost -State Connected | Sort-Object -Property MemoryUsageGB | Select-Object -First 1
$ESXiHostSrc = “esx01.wardvissers.nl”
$ESXiHostDst = “esx02.wardvissers.nl”
$vmList = Get-VMHost $ESXiHostSrc | Get-VM
$vmList | move-vm -destination (get-vmhost $ESXiHostDst)
}