Giter VIP home page Giter VIP logo

invoke-ciscocommand's Introduction

invoke-ciscocommand's People

Contributors

masters274 avatar

Stargazers

TheCave avatar Josh Lambert avatar Alexander Knorr avatar

Watchers

 avatar Chris avatar

invoke-ciscocommand's Issues

Error control try-catch causes failures of subsequent calls to Invoke-CiscoCommand

To add some error handling I tried to use the try-catch syntax when calling the Invoke-CiscoCommand but this resulted in the first run succeeding but all subsequent runs failed with the error message below. I am looping through a set of Cisco switch IPs so I can create a file using ConvertTo-CSV and have a file for each switch. After the loop finished the Get-SSHSession showed a new session open for each subsequent call to invoke-ciscocommand.

`Get-CiscoFCNS -IPAddress 10.xxx.xx.xxx -Credentials System.Management.Automation.PSCredential
Invoke-CiscoCommand -IPAddress 10.xxx.xx.xxx -command 'show fcns database local detail | json native' -Credential System.Management.Automation.PSCredential
Get-CiscoFCNS : Cannot convert value "Stream found for {0}" to type "System.Int32". Error: "Input string was not in a correct format."
At C:\Support\Scripts\GatherCiscoSanSwitchConfigs.ps1:126 char:15

  • ... $objFCNS = Get-CiscoFCNS -IPAddress $TheSwitch.IPAddress -Credential ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-CiscoFCNS`

Wrapping JSON Output

Running a cisco show command piped to json native results in some very long lines which were being split with a newline. This resulted in json which was invalid and could not be processed by ConvertFrom-Json. I had to edit the Invoke-CiscoCommand.psi and add terminal -width 511 to line 203 of your script to resolve this issue. You may want to consider adding this.

Set terminal length

    $Global:SshStream.WriteLine('terminal length 0 ; terminal width 511')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.