Cold Vmotion Script

Hi All,

Do we have any script for cold migration of multiple vm from one cluster to another.
Techie solutionVMware SpecialistAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Techie solutionVMware SpecialistAuthor Commented:
How can I connect to the server via cli also please guide from basic commands. I never performed it.
Murali SripadaCommented:
Connect vi-server vcenterfqdn
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

Techie solutionVMware SpecialistAuthor Commented:
Error: Invalid server certificate. Use Set-powerCLIConfigurationto set the value for the InvalidCertification option prompt.
Murali SripadaCommented:
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -confirm:$false
https://be-virtual.net/powercli-10-0-0-error-invalid-server-certificate/
http://www.pragmaticio.com/2015/01/vmware-powercli-suppress-vcenter-certificate-warnings/

You can set them to ignore and then connect through vi-server again

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Techie solutionVMware SpecialistAuthor Commented:
Used below command

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -ParticipateInCEIP $true
Murali SripadaCommented:
Before you try the steps in production, i request you to try in a lab setup environment and test the scripts..

Thanks,
MS
Jitu SSystem EngineerCommented:
Hi,

You can use below code to migrate multiple virtual machines at a time. You mentioned cold VMotion so I included a line to turn off the virtual machine gracefully and then migrate them to the destination. Please let me know if this helps.

$Servers = Get-Content "C:\temp\Servers.txt"
Foreach ($server in $servers)
{
Shutdown-VMguest $server -Confirm:$false
Write-Host -Foregroundcolorcolor Green "Virtual Machine Powered off"
Move-VM $server -Destination "Destination ESX IP or FQDN"
Write-Host -Foregroudcolorcolor Green "Virtual Machine Migrated to Destination"
}
Techie solutionVMware SpecialistAuthor Commented:
I am still fetching help on this.
Though it helped with few knowledge but script is throwing error as I need to change both source network and Datastore.
Techie solutionVMware SpecialistAuthor Commented:
I used below and was able to migrate them successfully #Put the path of the csv file
 $vms = Import-CSV "C:\test\Testback.csv"
 foreach ($vm in $vms)
 {
 #Assign Variables
 $VMName = ($vm.Name1,$vm.Name2)
 $VMHost = ($vm.Host)
 $DD = ($vm.Datastore)
 $OldNetwork = ($vm.OldNetwork)
 $Net = ($vm.Network)
 Write-Host $VMName
 Write-Host $vm.Host
 Write-Host $vm.Datastore
 Write-Host $vm.Network
 Write-Host $vm.OldNetwork
 #Power off vms
 Get-VM -Name $VMName | Shutdown-VMGuest
 #Where the VM gets Migrated 
 Move-VM -VM $VMName -Destination $VMHost -Datastore$DD
 Get-VM $VMName | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $Net -Confirm:$false
 #Power On VMs
 #Start-VM $VMName -Confirm 
 }
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Virtualization

From novice to tech pro — start learning today.