Advertisement
onejdc

Cisco Powershell

Mar 6th, 2018
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Import-Module SshShell
  2.  
  3. $elevatedPrompt = "#.$"
  4. $configPrompt = "(config)#.$"
  5. $objectPrompt = "object)#.$"
  6.  
  7. $s = New-SshSession -SshHost $asaIP -User $user -Password $password
  8. Send-SshCommand $s "enable" -Expect "Password:"
  9. Send-SshCommand $s "$elevatedPassword" -Expect $elevatedPrompt
  10.  
  11. Send-SshCommand $s "show run object id $objectId" -Expect $elevatedPrompt
  12.  
  13. if ($s.LastResult -match "does not exist") {
  14.     Send-SshCommand $s "conf t" -Expect $configPrompt
  15.     Send-SshCommand $s "object network $objectId" -Expect $objectPrompt
  16.     Send-SshCommand $s "description $description" -Expect $objectPrompt
  17.     Send-SshCommand $s "host $hostIP" -Expect $objectPrompt
  18.     Send-SshCommand $s "end" -Expect $elevatedPrompt
  19.     Send-SshCommand $s "write mem" -Expect "[OK]" -WaitUnlimitedOn "configuration...|Cryptochecksum|copied"
  20. }
  21.  
  22. Close-SshSession $s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement