Via powercli, I am trying to move vms from one virtual datacenter to another virtual datacenter, the issue i am having is with the portgroup switch
for example this is the command i am trying to execute:
$vm = "valid-vm_name"
$esx = "valid-hypervisor_name"
$ds = "valid-datastore_name"
$newPgName = "valid-new-portgroup_name"
VMware.VimAutomation.Core\Move-VM -VM $vm -Destination $esx -Datastore $ds -PortGroup $newPgName
The error message I am getting is:
Move-VM : Cannot bind parameter 'PortGroup'. Cannot convert the "POMA|GOM|GOM-PSO-Expansion" value of type "System.String" to type
"VMware.VimAutomation.ViCore.Types.V1.Host.Networking.VirtualPortGroupBase".
At D:\PowerCLI\move-vm_GSM.ps1:32 char:89
+ ... ove-VM -VM $vm -Destination $esx -Datastore $ds -PortGroup $newPgName
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Move-VM], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM
Unfortuantely, the new portgroup names have "|" pipes in them, the old portgroup was called "pocq_gom_pso_extend" and on the new virtual datacenter they are now called "POMA|GOM|GOM-PSO-Expansion".
Is there anyway to convert the "|" to unicode or something else that the move-vm will accept?
I have tried the "`", i have tried unicode "`u", i have tried "\" and none of these work.
If i try this whole process via vcenter "Move to" option, it works without any issues and allows me to select the new network\portgroup.
Thanks
MS
Can you try with (replace the | with a ?)
$newPgName = "POMA?GOM?GOM-PSO-Expansion"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No, still no luck:
pg= POMA?GOM?GOM-PSO-Expansion
Move-VM : Cannot bind parameter 'PortGroup'. Cannot convert the "POMA|GOM|GOM-PSO-Expansion" value of type "System.String" to type
"VMware.VimAutomation.ViCore.Types.V1.Host.Networking.VirtualPortGroupBase".
At D:\PowerCLI\move-vm_GSM.ps1:30 char:89
+ ... ove-VM -VM $vm -Destination $esx -Datastore $ds -PortGroup $newPgName
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Move-VM], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM
I even got the portgroup unique identifier and tried that too:
Move-VM : Cannot bind parameter 'PortGroup'. Cannot convert the "4f682794-3b24-41c6-aac3-67a790d8ce76" value of type
"System.String" to type "VMware.VimAutomation.ViCore.Types.V1.Host.Networking.VirtualPortGroupBase".
At D:\PowerCLI\move-vm_GSM.ps1:30 char:89
+ ... ove-VM -VM $vm -Destination $esx -Datastore $ds -PortGroup $newPgName
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Move-VM], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM
So i am wonder that it might not even be a PIPE issue???
I still see the vertical bar in that first try.
Are you sure the name is changed?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I have found the issue, it had nothing to do with the pipe...
I was assigning the new portgroup directly to a variable, like $pg="'POMA|GOM|GOM-PSO'" and then passing this to the move-vm command like: Move-VM -VM $vm -Destination $esx -Datastore $ds -PortGroup $pg
But in fact if I do this:
$newPgName = Get-VDPortgroup -Name $pg
Move-VM -VM $vm -Destination $esx -Datastore $ds -PortGroup $newPgName
This works, so it was never an issue with the PIPE....
Sorry about that, my move-vm is now working.
Regards
MS