I am trying to write a script to backup the config from several HP switches and copy it to a ftp server.
My problem is if I execute every command of the script one by one in the powershell it works and I get a txt file on the ftp server with the config in it. But if I run the whole script at once as a ps1 file the script runs and finishes but it does not execute the commands in the shell stream. I think I would have to send a return (execute) command in the shell stream after the command but I do not know how to do this in powershell. Here is my script:
New-SSHSession -ComputerName $ip -Credential (Get-Credential) -AcceptKey</p>
$session = Get-SSHSession -ComputerName $ip
$stream = New-SSHShellStream -Index $session.SessionID
$stream.WriteLine("Copy running-config tftp NOACTUALIP outtaNoida.txt pc")
$result = $stream.Read()
Remove-SSHSession -Index 0
$ip = "10.66.12.119"