08-31-2020 01:25 AM
I'm using PowerShell with the modules posh-ssh and posh-cisco and i want to create a Backup of my Switch-Configuration.
Below my Script, I'm not a pro, and this is my first little Script. Everything works when i try other commands than "copy running-config" because that command needs to be executed in privileged mode. I searched around the Internet but i never found anything helpful.
Manually in PuTTY i need to type in "enable", then "password" then i can execute my command, how can i implement that into my script without getting too complicated?
This is my Script now:
$creds = Get-Credential
$sw_ssh = New-SshSession -ComputerName -Credential $creds -AcceptKey -
ConnectionTimeout 300
$cmd_backup = "copy running-config LOCATION vrf management"
Invoke-sshcommand -Command $cmd_backup -SSHSession $sw_ssh
08-31-2020 06:12 AM
you need not use coppy runnin-config ???
you need a command from the installed posh-cisco module
PS> Backup-CiscoRunningConfig -HostAddress "192.168.1.1" -HostPort 22 -Credential (Get-Credential) -FilePath "$([Environment]::GetFolderPath(“MyDocuments”))\running-config.txt"
08-31-2020 11:48 PM
I tried it out, it works without failures, but the output on the text file is wrong, i only get 1 sentence.
Line has invalid autocommand "show running-config"
As mentioned above, it's probably because somehow the admin user which i use haven't the right privileges. When i connect manually via PuTTY i first need to type "enable" and then the password, else i get the failure above again.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide