Take backup of switch configuration using powershell

Snehasish Nandy 1 Reputation point

Hi All,

I am trying to automation the below steps through powershell


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 = ""  
$FTPUser = ""  
$FTPPass = ""  

# Access details for the FC switches. All switches must have the same login credentials  
$FCSwitches = @("")  
$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,UserName,/home/Storage/Monthly_Backup/,password  

when I am trying same command from putty, it is asking for password again. once I enter it is executing


Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,273 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 43,926 Reputation points

    Why not use "-batch" as a parameter for plink.exe? That suppresses all interactive prompts.