The following is a test command I am running
$PCCreds = Get-Credential$VM = Get-VM -Name "Test-VM"while ($VM -ne $null){$VM | Invoke-VMScript -GuestCredential $PCCreds -ScriptType Bat -ScriptText 'whoami'Start-Sleep -Seconds 10}
While in this infinite loop I will receive a mixture of successes and failures
ScriptOutput ---------------------------------------------------------------------------------------------------------------------- Test-VM\user | ---------------------------------------------------------------------------------------------------------------------- Invoke-VMScript : 7/9/2012 11:22:12 AM Invoke-VMScript While performing operation 'Connect to host service ' https://vcenter.local/sdk' at port 902' the following error occured: 'Unknown error' At line:15 char:45 + while ($VM -ne $null) {$VM | Invoke-VMScript <<<< -GuestCredential $PCCreds -ScriptType Bat -ScriptText 'whoami'
Start-Sleep -Seconds 60} + CategoryInfo : OperationStopped: (:) [Invoke-VMScript], VimException + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_VixWaitForJob_VixError,VMware.VimAutomation.ViCore.Cmdlets. Commands.InvokeVmScript ScriptOutput ---------------------------------------------------------------------------------------------------------------------- Test-VM\user | ----------------------------------------------------------------------------------------------------------------------
Using that same code with an array of vm objects appears to work without issue. These vms are spread across multiple hosts.
My guess is that this has something to do with sequential connections to same host, reaching a max connection limit, and the connection not being terminated after a successful execution of the cmdlet. Anyone seen this issue before?