Advertisement
Guest User

Untitled

a guest
May 8th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. Import-Module posh-ssh
  2. $UserName ="gtrf\Sinyakov.Roman"
  3. $PasswordFile = "d:\Password.txt"
  4. #$Credentials=Get-Credential|ConvertTo-SecureString -AsPlainText -Force
  5. $Password=Get-Content $PasswordFile | ConvertTo-SecureString
  6. #$Credentials | ConvertFrom-SecureString | Out-File $File
  7. $Creds = new-object System.Management.Automation.PSCredential ($UserName, $Password)
  8. $Session = New-SSHSession -ComputerName fanta.gtrf.local -Credential $Creds -AcceptKey -Verbose
  9. $SSHSes = Get-SSHSession
  10. $SSH = $Session.Session.CreateShellStream("dump",0,0,0,0,1000)
  11. $Stream = $Session.Session.CreateShellStream("dumb", 0, 0, 0, 0, 1000)
  12. #Write-Host ("Посылаем команду на коммутатор") -ForegroundColor Green
  13. $SSH.Write(" "+"Show")
  14. $SSH.Read()
  15. #$Stream.Read()
  16. #Write-Host $Stream
  17. #$Stream.Write("copy running-config tftp://tools.gtrf.local;;;")
  18. #Invoke-SSHCommandStream -SSHSession $Session -Command ("copy running-config tftp://tools.gtrf.local;;")
  19. #Invoke-SSHCommand -SSHSession $Session -Command ("copy running-config tftp://tools.gtrf.local;;")
  20. #Invoke-SSHStreamExpectAction -Command "'n"
  21. #Invoke-SSHCommandStream -SSHSession $Session -Command ("n")
  22. #Get-SSHSession -Verbose | fl
  23. Remove-SSHSession $Session
  24. #Remove-SSHSession -SessionId 2 -Verbose
  25. #Remove-SSHSession -SessionId 1 -Verbose
  26. #Remove-SSHSession -SessionId 3 -Verbose
  27. #Remove-SSHSession -SessionId 0 -Verbose
  28. #Get-Credential $Credentials
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement