cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
13232
Views
0
Helpful
2
Replies

How i get into the "enable" mode via SSH with Powershell

Domiking
Level 1
Level 1

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

2 Replies 2

pieterh
VIP
VIP

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"

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.