Advertisement
Guest User

Powershell switch configs

a guest
Apr 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ErrorActionPreference ="Inquire"
  2. Import-Module SSH-Sessions
  3.  
  4. $date = "$(get-date -f yyyy-MM-dd)"
  5. $filename = 'config.txt'
  6. #$ext = 'txt'
  7. $filepath ='output\'
  8.  
  9.  
  10. #list of IP addresses, one per line. No whitespace before/after
  11. $list = Get-Content .\input\IP.txt
  12.  
  13. #username
  14. $user = 'foobar'
  15.  
  16. #password
  17. $pass = 'test'
  18.  
  19. #ip address
  20. $ip = '192.168.0.222'
  21.  
  22.  
  23. New-SshSession $list -Username $user -KeyFile C:\scripts\1024sshpriv.key
  24. #New-SshSession $ip -Username $user -Password "$pass"
  25.  
  26. $cmd = "more system:running-config"
  27.  
  28. #Invoke-Sshcommand -InvokeOnAll -Command "$cmd" | Out-File "$filepath$filename-$date$ext"
  29. Invoke-Sshcommand -InvokeOnAll -Command "$cmd" | Out-File "$filepath$filename"
  30.  
  31. Remove-SshSession -RemoveAll
  32. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement