Microsoft Virtualization Discussions

Powershell Toolkit 4.6 & Invoke-NaSsh

Hello,

 

I'm running a powershell script to collect some ifgrp informations from my 7-mode filers (powershell via putty).

 

 $IfGrpStatus = Invoke-NaSsh "ifgrp status $($ifgrp)"

How I can close current sessions, which were opened by my script?
The Problem is, after I start my script I can't login to my filer:

 

/sbin/ngsh: Too many users
Connection to XXXXXX closed.

 

Everytime I have to disconned all sessions with ssh FILER logout telnet command and that's not comfortable for my usage.

 

Thank you and regards,

Lukas

3 REPLIES

Re: Powershell Toolkit 4.6 & Invoke-NaSsh

Hi Lucas,

 

You could try to use "Invoke-NaSystemApi" instead of "Invoke-NaSsh". I've posted some powershell examples here:

 

https://community.netapp.com/t5/Microsoft-Cloud-and-Virtualization-Discussions/NetApp-PowerShell-Toolkit-4-5P1-released/td-p/138566/highlight/true/pag...

 

Hope that helps

 

/Matt

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

Highlighted

Re: Powershell Toolkit 4.6 & Invoke-NaSsh

Hi Matt,

 

can you please show me how I can get vif-name and containing online links via Invoke-NaSystemApi ? I'm not able to get this informations...

 

Thank you,

Lukas

Re: Powershell Toolkit 4.6 & Invoke-NaSsh

Hi Lukas,

 

Here is an "example" for you to modify to meet the requirements of your environment.

 

Source Code:

 

 

<#'-----------------------------------------------------------------------------
'Script Name : GetIfGrp.ps1
'Author      : Matthew Beattie
'Created     : 2018-06-21
'Description : This script connects to a 7-Mode controller and enumerates ifgrps.
'-------------------------------------------------------------------------------
'Functions Section
'-----------------------------------------------------------------------------#>
Param(
   [Parameter(Mandatory=$True, HelpMessage="The 7-Mode controller name or IP Address")]   
   [String]$Controller,
   [Parameter(Mandatory=$False, HelpMessage="The credentials to connect to the controller")]   
   [System.Management.Automation.PSCredential]$Credentials
)
#'------------------------------------------------------------------------------
#'Import the DataONTAP powershell module
#'------------------------------------------------------------------------------
Import-Module DataONTAP
#'------------------------------------------------------------------------------
#'Prompt for credentials if not provided.
#'------------------------------------------------------------------------------
If(-Not($Credentials)){
   $Credentials = Get-Credential
}
#'------------------------------------------------------------------------------
#'Connect to the Controller
#'------------------------------------------------------------------------------
Try{
   Connect-NaController -Name $Controller -Credential $Credentials -ErrorAction Stop | Out-Null
   Write-Host "Connected to ""$Controller"""
}Catch{
   Write-Warning -Message $("Failed connecting to ""$Controller"". Error " + $_.Exception.Message)
   Break;
}
#'------------------------------------------------------------------------------
#'Enumerate the Interface groups.
#'------------------------------------------------------------------------------
[Array]$command = @("ifgrp", "status")
 Try{
   $api = $("<system-cli><args><arg>" + ($command -join "</arg><arg>") + "</arg></args></system-cli>")
   $output = Invoke-NaSystemApi -Request $api -ErrorAction Stop
   Write-Host $("Executed Command`: " + $([String]::Join(" ", $command)))
}Catch{
   Write-Warning -Message $("Failed Executing Command`: " + $([String]::Join(" ", $command)) + ". Error " + $_.Exception.Message)
   Break;
}
#'------------------------------------------------------------------------------
#'Format the command output if the command result was sucessfull.
#'------------------------------------------------------------------------------
If($output.results."cli-result-value" -eq 1){
   [Array]$lines = $output.results."cli-output".Trim().Split("`n")
   ForEach($line In $lines){
      [String]$result   = $($line -Replace("\s+", " ")).Trim();
      [Array]$elements += $result
   }
   ForEach($element In $elements){
      Write-Host $element
   }
}
#'------------------------------------------------------------------------------

 

 

 

Example output:

 

 

 

PS C:\Scripts\PowerShell\Projects\GetIfGrp> .\GetIfGrp.ps1 -Controller testns01 -Credentials $Credentials
Connected to "testns01"
Executed Command: ifgrp status
default: transmit 'IP Load balancing', Ifgrp Type 'multi_mode', fail 'log'
ifgrp1: 2 links, transmit 'IP Load balancing', Ifgrp Type 'multi_mode' fail 'default'
Ifgrp Status Up Addr_set
up:
e0d: state up, since 21Jun2018 11:56:37 (00:37:38)
mediatype: auto-1000t-fd-up
flags: enabled
input packets 1, input bytes 64
output packets 0, output bytes 0
up indications 1, broken indications 0
drops (if) 0, drops (link) 0
indication: up at 21Jun2018 11:56:37
consecutive 2118, transitions 1
e0c: state up, since 21Jun2018 11:56:31 (00:37:44)
mediatype: auto-1000t-fd-up
flags: enabled
input packets 1, input bytes 64
output packets 0, output bytes 0
up indications 1, broken indications 0
drops (if) 0, drops (link) 0
indication: up at 21Jun2018 11:56:31
consecutive 2124, transitions 1

Hope that helps

 

/Matt

 

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

Forums