Apply the following code, the cloning does it without problems, but at the moment of configuring the MAC to VM cloned it shows me the following error:
Error
-------------------------------------------
Set-NetworkAdapter : 2/7/2019 3:14:46 PM Set-NetworkAdapter The MAC address is invalid or is not in the valid range
00:50:56:00:00:00 - 00:50:56:3F:FF:FF.
At C:\Users\Marco\Desktop\clonacion.ps1:23 char:49
+ ... rkAdapter | Set-NetworkAdapter -MacAddress (Get-VM -Name $VMsource | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-NetworkAdapter], InvalidArgument
+ FullyQualifiedErrorId : Common_SharedParameterHelper_TryValidateStaticMacAddress_InvalidMacAddress,VMware.VimAut
omation.ViCore.Cmdlets.Commands.VirtualDevice.SetNetworkAdapter
SCRIPT
----------------------------------
##Connect to vCenter
connect-viserver -server $vcenter_server -User $vcenter_user -Password $vcenter_pwd
##Elimina VM de hasta 7 dias
Get-VM -Name $oldCloneName -ErrorAction SilentlyContinue | Remove-VM -DeletePermanently:$true -Confirm:$false
##Clone VM, disco virtual tipo thick y carpeta de almacenaiento de la VM
New-VM -VM $VMsource -Name $newVMclone -VMHost $esxi -DiskStorageFormat Thin -Location "Laboratorios"
##Asignar MAc de la VM origen
Get-VM -Name $newVMclone | Get-NetworkAdapter | Set-NetworkAdapter -MacAddress (Get-VM -Name $VMsource | Get-NetworkAdapter).MacAddress