Thank you, that was exactly what I was looking for! Really appreciate that you took the time. Beer on me if we ever meet!
I believe that the script is working correctly now. Did edit some issues, so I posted it below if someone want to use it.
The problem now is possibly something with Move-VM command. On all VM's (both powered on and off) there is "Unable to access the virtual machine configuration: Unable to access file"
Even though the vMotion is between two clusters without shared storage, I can indeed vMotion both storage and compute online with vSphere Client. Using vCenter 6.7 U1.
Found in another thread where LucD helped out with a similar issue. There the solution was to specify cluster, using -Location $cluster, which I did but I still get the same error.
Any suggestions?
Thanks again! ![]()
Move-VM : 2019-06-02 23:30:04 Move-VM The operation for the entity "migrationtest1" failed with the following message: "Unable to access the virtual machine configuration: Unable to access file [nfs_04]"
At C:\Powershell\VMware\Migrate-VM-Storage.ps1:38 char:4
+ Move-VM -VM $vm -Destination $destinationEsx -Datastore $destinati ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Move-VM], CannotAccessVmConfig
+ FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM
Here is my edited script! Note I had to comment out -header
$csvinput = Import-Csv -Path "C:\Powershell\CSV\migtest.csv" -Delimiter ";" # -Header Name,PortGroup,DestinationPG,VMhost,DestinationVMhost,Datastore,DestinationDS,DrsGroup
$targetCluster = "metro-1"
ForEach ($row in $csvinput){
$vm = Get-VM -Name $row.Name
$cluster = Get-Cluster -Name $targetCluster
$destinationEsx = Get-VMHost -Name $row.DestinationVMhost -Location $cluster
$networkAdapter = Get-NetworkAdapter -VM $vm
$destinationPortGroup = Get-VDPortgroup -VDSwitch 'vDS-Prod-01' -Name $row.DestinationPG
$destinationDatastore = Get-Datastore $row.Datastore
Move-VM -VM $vm -Destination $destinationEsx -Datastore $destinationDatastore -NetworkAdapter $networkAdapter -PortGroup $destinationPortGroup -DiskStorageFormat Thin
}