You mention that you have multiple connections to vSphere servers open.
Are these all vCenters, or are they ESXi servers ?
Could it be that 1 such connection was dropped after the error ?
You could insert a
$global:DefaultVIServers.Count
before and after line 12 to check if that is the case.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference