The transition to NetApp MS Azure AD B2C is complete. If you missed the pre-registration, you will be invited to register at next log in.
Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Microsoft Virtualization Discussions

Invoke-NcSsh Does Not Close Putty


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?






I think your issue might relate to BUG #1167414. A workaround would be to use "Invoke-NcSystemApi" instead of "Invoke-NcSsh" to avoid using Putty. I posted an example here:


Hope that's useful



If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.


Well that's a match, thanks for pointing it out.  I'll follow that BURT.  I don't think I can get what I need from the API but I'm going to try som ideas.  Thanks again.



I see that BUG 1167414 is not fixed.

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.


Thank you 



I'm checking with engineering, but I think this was fixed but just not updated in the bug report to reflect as such.  Are you getting the same issue even with the most current PowerShell toolkit?


Thanks for the response.

I could fix the issue within the script by applying workaround commands.

Currently, I'm using the PowerShell toolkit version 4.4. Will install the latest PS Toolkit version to see if the issue is resolved.

Thank you




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.

Thanks for the help 🙂


NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner