Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module posh-ssh
- $UserName ="gtrf\Sinyakov.Roman"
- $PasswordFile = "d:\Password.txt"
- #$Credentials=Get-Credential|ConvertTo-SecureString -AsPlainText -Force
- $Password=Get-Content $PasswordFile | ConvertTo-SecureString
- #$Credentials | ConvertFrom-SecureString | Out-File $File
- $Creds = new-object System.Management.Automation.PSCredential ($UserName, $Password)
- $Session = New-SSHSession -ComputerName fanta.gtrf.local -Credential $Creds -AcceptKey -Verbose
- $SSHSes = Get-SSHSession
- $SSH = $Session.Session.CreateShellStream("dump",0,0,0,0,1000)
- $Stream = $Session.Session.CreateShellStream("dumb", 0, 0, 0, 0, 1000)
- #Write-Host ("Посылаем команду на коммутатор") -ForegroundColor Green
- $SSH.Write(" "+"Show")
- $SSH.Read()
- #$Stream.Read()
- #Write-Host $Stream
- #$Stream.Write("copy running-config tftp://tools.gtrf.local;;;")
- #Invoke-SSHCommandStream -SSHSession $Session -Command ("copy running-config tftp://tools.gtrf.local;;")
- #Invoke-SSHCommand -SSHSession $Session -Command ("copy running-config tftp://tools.gtrf.local;;")
- #Invoke-SSHStreamExpectAction -Command "'n"
- #Invoke-SSHCommandStream -SSHSession $Session -Command ("n")
- #Get-SSHSession -Verbose | fl
- Remove-SSHSession $Session
- #Remove-SSHSession -SessionId 2 -Verbose
- #Remove-SSHSession -SessionId 1 -Verbose
- #Remove-SSHSession -SessionId 3 -Verbose
- #Remove-SSHSession -SessionId 0 -Verbose
- #Get-Credential $Credentials
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement