I may be having a similar problem. I am getting the following error:
PS> Invoke-VMScript -VM CentOS7 -ScriptText 'sed -ri "s|10.28.183.204|10.28.164.138|" /etc/sysconfig/network-scripts/ifcfg-ens192' -GuestUser root -GuestPassword password
Invoke-VMScript : 12/3/2020 5:12:26 PM Invoke-VMScript An error occurred while sending the request.
At line:1 char:1
+ Invoke-VMScript -VM CentOS7 -ScriptText 'sed -ri "s|10.28.183. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-VMScript], ViError
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DownloadFileFromGuest_DownloadError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript
After hitting enter on the PS command, it takes 3 minutes 52 seconds (I used a stopwatch) before PS returns the error message but the SED change is made on the host within a few seconds. Why is the console hanging up for 3m52s before returning the error but the command executed within seconds on the host?
GuestOS: CentOS7_1908 w/ VMWare Tools v11.0.5.17716 running
PowerShell v5.1.14393.2969 with PowerCLI v12.1.0 on Win Svr 2016
Thanks!