Issue with PowerCLI: Not authenticated and session timeout

A colleague of mine experienced this issue recently where after making a PowerCLI connection to a vCenter and instantly running a command such as Get-VM, he would be prompted by the error:


Get-VM. Not authenticated. Possible cause of this error is that the connection was left unused for a while and session has timed out.

Checking he was connected to a vCenter appeared to indicate that he was, i.e.


$global:defaultVIServer

returned a value. Seems like this may be an issue with PowerCLI 5.1 since other similar reports indicate reverting to 4.1 does not have the issue.

We didn’t have that option, so in this instance took the recommendation to amend the PowerCLI timeout as follows, which seemed to help in our case:


Set-PowerCLIConfiguration -WebOperationTimeoutSeconds -1