- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've updated my script and powercli version to 12.4 but the problem is always present. Below the script and the output:
import-csv $csvinput | foreach {
$name = get-vm $_.Name
$clustercible = get-cluster $_.clustercible
$targetds = get-datastorecluster $_.targetds
$ds1=get-datacenter "dc_old" | Get-Datastore | where {$_.Name -eq "DSD_migration"}
$ds2=get-datacenter "dc_maq" | Get-Datastore | where {$_.Name -eq "DSD_migration"}
#Get-VM ($name) | Move-VM -Datastore $ds1 -RunAsync -Confirm:$false
#Get-VM ($name) | Move-VM -Destination $clustercible -Datastore $ds2
Move-VM -VM $name -Destination $clustercible -Datastore $ds2
$vm.ExtensionData.RelocateVM($spec, [VMware.Vim.VirtualMachineMovePriority]::defaultPriority)
}
PS D:\Alexandre\Script> .\test1.ps1 .\liste_VMs.csv
Name Port User
---- ---- ----
vcenter 443 xxxxxxxxxx
Move-VM : 18/11/2021 09:21:43 Move-VM Object reference not set to an instance of an object.
At D:\Alexandre\Script\test1.ps1:24 char:1
+ Move-VM -VM $name -Destination $clustercible -Datastore $ds2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Move-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM
Do you have ideas to resolve this problem ?