Running below command on linux machine and it fails with below error:
Invoke-VMScript <<<< -VM $machine.Name -ScriptType Bash -GuestUser $UserName -GuestPassword $Password -ScriptText $cmd -ToolsWaitSecs 400
Error:
Invoke-VMScript The underlying connection was closed: An unexpected error occurred on a receive.
+ CategoryInfo : NotSpecified: (:) [Invoke-VMScript], ViError
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DownloadFileFromGuest_DownloadError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript
Disconnect and connect back to VI server, this should fix the problem. Disconnect-VIServer -Server * -Confirm:$false -Force Connect-VIServer -Server $vcIP -Protocol https -User $vcUser -Password $vcPW