Using PowerShell Toolkit 4.6 and Putty 0.70. Using the Invoke-NcSsh cmdlet. Used the same cmdlet in the same script prior to upgrading the toolkit without issue. The cmdlet functions; however, when the SSH data is returned, the SSH session is not closed and Putty remains open. This creates a problem if calling Invoke-NcSsh multiple times in the same script. Without it gracefully exiting you can get beyond the maximum SSH sessions on the cluster with an alert such as this:
xinetd.hit.per.source.limit: Maximum number of network connections of 32 received from the remote host x.x.x.x for the service ssh.
And then while calling the cmdlet in this condition you get this:
Invoke-NcSsh : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index At C:\Downloads\RiskResolverCertificate.ps1:306 char:34 + $GetCertificateResults = Invoke-NcSsh $GetCertificateCommand + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidResult: (:) [Invoke-NcSsh], ArgumentOutOfRangeException + FullyQualifiedErrorId : SshExecFailed,DataONTAP.C.PowerShell.SDK.Cmdlets.Toolkit.Ssh.InvokeNcSsh
Is there a cmdlet that should be called to close the SSH session or a parameter to pass to ensure it is closed?
Could you please suggest an alternative solution to overcome this BUG, if you have any
I'm using Powershell for storage automation, the PS script will communicate to NetApp (ONTAP Cloud Ver:9.3) to pull the snap list information. Since, the SSH sessions are not being closed after each query. I get the error "Invoke-NcSsh : Index was out of range. Must be non-negative and less than the size of the collection".
I've to kill the SSH session for the query to work again.
I installed the latest NetApp's PowerShell tool kit (ver 9.6.0). I don't see multiple stale ssh connection after the query. But, it maintains one stale SSH connection always even after completion of the query.
The conclusion is that with the latest PS kit, issue is minimized but not resolved completely.
I'm good with the workaround that I found for this issue.