- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I begin with this script but I have an error when I want to do a vMotion on another cluster
$csvinput = $args[0]
import-csv $csvinput | foreach {
$name = $_.Name
$clustercible = $_.clustercible
$targetds = $_.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
}
I have this error:
Move-VM : 17/11/2021 12:20:07 Move-VM Object reference not set to an instance of an object.
At D:\Alexandre\Script\test1.ps1:40 char:18
+ Get-VM ($name) | Move-VM -Destination $clustercible -Datastore $ds2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Move-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM