Hello friends,
I’m currently working on trying to migrating virtual machines to a new datacenter. Networks are identical (stretched) in both datacenters but we have to do a svmotion to move between them.
I’ve cobbled together a powercli script from various sources that basically imports today selected VM’s through a CSV, then cycles through it while spawning new Move-VM’s once the running sessions is under a predefined threshold. But, I’m running into issues with migrating systems that are on standard switches over to distributed switched. Port group names are all identical, so I figured I could just use the name element in the destinations port group. It seems to have worked ok on system with a single nic, but I started running into issues with multiple nics.
I ran across an article by Kyle Ruddy – Spotlight on the Move-VM Cmdlet including PowerCLI 6.5 Enhancements that showed you can pipe arrays. I also found an article that LucD was helping on which was more recent, move-vm script placing port groups on wrong adapters for VMs with multiple nics but have still been unable to resolve my issues.
Snipped of code for picking the network adapter:
# Pick target port group based on source port group name. Cycle through for multiple network adapters
$NetworkAdapter = Get-NetworkAdapter -vm $vm
$targetpg = @()
$NetworkAdapter.count | foreach-object {
$targetpg += Get-VDPortgroup -name $NetworkAdapter.networkname
}
Move VM command:
Move-VM -VM $vm `
-Destination $DestinationHost `
-NetworkAdapter $NetworkAdapter `
-PortGroup $targetpg `
-Datastore (Get-DatastoreCluster -Name $DestinationDatastore | Get-Datastore | Sort-Object -Property FreeSpaceGB -Descending | Select -First 1) `
-RunAsync -Confirm:$false
But when I am currently getting the following error:
Move-VM : 10/31/2020 2:12:56 PM Move-VM A specified parameter was not correct: RelocateSpec
At line:1 char:1
+ Move-VM -VM $vm `
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Move-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM
I tried using the sdk method but never could get it to work with standard switch moves.
Any insight or help would be much appreciated. Thanks!!