'Accessing a menu on a cisco system in SSH using Plink
I'm working on automating the extract of a report on a cisco system (ISE in that case), to do that i'm using poweshell and the Plink component of the PuTTy suite.
I manage to automate the connection and run simple task, but when it come to generate the report you need to go throught a menu :
SERVER/@User# application configure ise
Selection configuration option
[1]Reset M&T Session Database
[2]Rebuild M&T Unusable Indexes
[3]Purge M&T Operational Data
[4]Reset M&T Database
[5]Refresh Database Statistics
[6]Display Profiler Statistics
[7]Export Internal CA Store
[8]Import Internal CA Store
[9]Create Missing Config Indexes
[10]Create Missing M&T Indexes
[11]Enable/Disable ACS Migration
[12]Generate Daily KPM Stats
[13]Generate KPM Stats for last 8 Weeks
[14]Enable/Disable Counter Attribute Collection
[15]View Admin Users
[16]Get all Endpoints
[17]Enable/Disable Wifi Setup
[18]Reset Config Wifi Setup
[19]Establish Trust with controller
[20]Reset Context Visibility
[21]Synchronize Context Visibility With Database
[22]Generate Heap Dump
[23]Generate Thread Dump
[24]Force Backup Cancellation
[25]CleanUp ESR 5921 IOS Crash Info Files
[26]Configure TCP params
[27]Recreate undotablespace
[28]Fetch SGA/PGA Memory usage
[0]Exit
All in need to do to generate the report is typing 16 but when i try to automate this process the flow of command can't pass this menu.
Here's some of the script i tried to use :
The easiest version
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
Set-Alias plink $plinkPath
$t = "SERVER"
$l = "@User"
$pw = "SoMePaSSwOrD"
echo application configure ise 0 exit | plink -ssh -pw $pw -t $t -l $l
Normal version :
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
Set-Alias plink $plinkPath
$t = "SERVER"
$l = "@User"
$pw = "SoMePaSSwOrD"
plink -ssh -pw $pw -t $t -l $l "application configure ise 0 exit"
Using System.Diagnostics.Process :
$ProcessStartInfo = New-Object System.Diagnostics.ProcessStartInfo
$ProcessStartInfo.UseShellExecute = $false
$ProcessStartInfo.RedirectStandardError = $true
$ProcessStartInfo.RedirectStandardInput = $true
$ProcessStartInfo.RedirectStandardOutput = $true
$ProcessStartInfo.FileName = "C:\Program Files\PuTTY\plink.exe"
$t = "SERVER"
$l = "@User"
$pw = "SoMePaSSwOrD"
$ProcessStartInfo.Arguments = "-ssh -t $t -l $l -pw $pw"
$Process = New-Object System.Diagnostics.Process
$Process.StartInfo = $ProcessStartInfo
$Process.Start() | Out-Null
$Process.StandardInput.WriteLine("application configure ise")
#Start-Sleep -m 3000
$Process.StandardInput.WriteLine("0")
$Process.StandardInput.WriteLine("exit")
$Process.WaitForExit()
$stdoutput = $Process.StandardOutput.ReadToEnd()
$erroutput = $Process.StandardError.ReadToEnd()
Write-Host "Standard Output: $stdoutput"
Write-Host "Error Output : $erroutput"
Write-Host "exit code: " + $Process.ExitCode
But all of these method result in the same way, no crash just blocked in the menu waiting for an input.
Just some clarification :
-No i don't use the Posh-SSH module it simply doesn't work (no output, no effect ...)
-The -m (path to a .txt file with the flow of command) in the line plink -ssh -pw $pw -t $t -l $l doesn't work either (it's apparently a known issue on cisco systems)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
