Take backup of switch configuration using powershell

Snehasish Nandy 6 Reputation points
2021-12-16T11:37:06.93+00:00

Hi All,

I am trying to automation the below steps through powershell

![158224-image.png]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

158214-image.png

Windows for business Windows Server User experience PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2021-12-16T16:02:47.46+00:00

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

    plink-options.html


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.