VMware Cloud Community
dampfross
Contributor
Contributor

PowerCli looses connection to vcenter

I have a PowerCli script to move guests to another datastore. After moving some guests, the script will loose the connection after approx. 10 minutes to the vcenter. Surely, moving lasts just a few minutes - additionaly I have to restart the powershell Session after the break and to change the .csv file. Any ideas solving this lousy problem are welcome 😉

Snippets:
Function Main {
   Get-Module -Name VMware* -ListAvailable | Import-Module
   Set-PowerCLIConfiguration -WebOperationTimeoutSeconds 1800 -Confirm:$false
   $vms = Import-Csv \\verein\sys\admin\PScript\VMware\VCenter01\MoveDatastore.csv -UseCulture
   Connect-VIServer vCenter01

   foreach ($VM in $VMs) {
      Move-VM -VM $VM -Datastore $($VM.NewStore) -DiskStorageFormat 'Thick'
   }
}

 

0 Kudos
42 Replies
beefy147
Enthusiast
Enthusiast

Great news. Thanks for the effort to get this information. I will test it this week on our 8.x instances and report back 🙂

0 Kudos
FrankWW
Contributor
Contributor

This solved it for me. No more object reference not found after a reboot of a host when executing an maintenance script.

Thanks!

0 Kudos
burchell99
Enthusiast
Enthusiast

Also confirmed as solved. thank you

0 Kudos