Why not use "-batch" as a parameter for plink.exe? That suppresses all interactive prompts.
Take backup of switch configuration using powershell
Snehasish Nandy
1
Reputation point
Hi All,
I am trying to automation the below steps through powershell
]2
I have written the below code to do this, but when I am executing the command it is going to a hang mode and not getting any output.
# Create a variable based on the date in the format of YYYYMMDD
$DateStamp = Get-Date -UFormat "%Y%m%d"
# Set the location of the Putty Link executable
$PLinkBin = "C:\Program Files\PuTTY\plink.exe"
# Access details for destination FTP server
$SFTPServer = "10.12.8.13"
$FTPUser = ""
$FTPPass = ""
# Access details for the FC switches. All switches must have the same login credentials
$FCSwitches = @("192.168.7.1")
$FCSwitchUser = ""
$FCSwitchPass = ""
#Loop through each of the FC switches, creating a file name in the formate of Name-YYYYMMDD.txt.
#Login to each switch and run the configupload command to backup to the FTP server.
ForEach ($FCSwitch in $FCSwitches){
$BackupFileName = "/home/Storage/Monthly_Backup/$FCSwitch-$DateStamp.txt"
$BackupCommand = "configupload -all -sftp $SFTPServer,$FTPUser,$BackupFileName,$FTPPass"
#& $PLinkBin -pw $FCSwitchPass $FCSwitchUser@$FCSwitch $BackupCommand
@(echo y | & $PLinkBin -pw $FCSwitchPass $FCSwitchUser@$FCSwitch $BackupCommand)
}
Please if anyone can help me out on this
below command I am trying. this time it is coming out of prompt but file not getting created. no error also
configupload -all -p sftp 10.1.8.13,UserName,/home/Storage/Monthly_Backup/192.168.1.7-20211215.txt,password
when I am trying same command from putty, it is asking for password again. once I enter it is executing