{"id":104,"date":"2014-05-15T21:35:25","date_gmt":"2014-05-15T21:35:25","guid":{"rendered":"http:\/\/www.edrockwell.com\/blog\/?p=104"},"modified":"2014-05-16T01:32:57","modified_gmt":"2014-05-16T01:32:57","slug":"ssh-powershell-backup-cisco-devices-script","status":"publish","type":"post","link":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/","title":{"rendered":"SSH with Powershell: Backup multiple Cisco devices"},"content":{"rendered":"<p>Today, I was asked to write a script to connect to all our Cisco devices and backup the configs to our fileserver. After a few hours of figuring it out, this is what I came up with<\/p>\n<p>You ONLY need a READ ONLY account on the Cisco devices.<\/p>\n<p>We run this every day at 2:00 AM and backup many Cisco devices.<\/p>\n<p>I downloaded and use this SSH.NET Library: <a href=\"http:\/\/www.powershelladmin.com\/wiki\/SSH_from_PowerShell_using_the_SSH.NET_library\">SSH With Powershell<\/a><\/p>\n<p>You have to move it to your powershell modules directory and then import-module<\/p>\n<pre lang=\"POWERSHELL\">##################################\r\n# Ed Rockwell\r\n# Requires SSH Module from here:\r\n# http:\/\/www.powershelladmin.com\/wiki\/SSH_from_PowerShell_using_the_SSH.NET_library\r\n# When downloading the above, you need to right click the download and unblock it in the properties\r\n# Then add the contents to your powershell modules\r\n# Free to distribute! Keep: http:\/\/www.EdRockwell.com\r\n# 5\/15\/2014\r\n\r\nImport-Module SSH-Sessions\r\n\r\n$FileServerLocation = '\\\\path\\to\\file\\server\\'\r\n$DeviceList = Get-Content '\\\\path\\to\\text\\file\\of\\devices\\NetworkDeviceList.txt'\r\n$Date = (Get-Date -f yyyyMMdd)\r\n\r\nmd $Date\r\ncd $Date\r\n\r\nforeach ($Device in $DeviceList)\r\n{\r\nNew-SSHSession -ComputerName $Device -Username YourCiscoUser -Password Password4CiscoUser\r\n$DeviceBackup = Invoke-SshCommand -ComputerName $Device -Command 'show start'\r\n$DeviceBackup | out-file $device'.txt'\r\n}\r\n\r\ncd ..\r\nMove-Item $Date $FileServerLocation<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today, I was asked to write a script to connect to all our Cisco devices and backup the configs to our fileserver. After a few hours of figuring it out, this is what I came up with You ONLY need a READ ONLY account on the Cisco devices. We run this every day at 2:00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,16,8],"tags":[54,55,21],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-cisco","category-powershell","category-scripting","tag-backup","tag-cisco-2","tag-powershell-2"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SSH with Powershell: Backup multiple Cisco devices - System Admin [RESOLVED]<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SSH with Powershell: Backup multiple Cisco devices - System Admin [RESOLVED]\" \/>\n<meta property=\"og:description\" content=\"Today, I was asked to write a script to connect to all our Cisco devices and backup the configs to our fileserver. After a few hours of figuring it out, this is what I came up with You ONLY need a READ ONLY account on the Cisco devices. We run this every day at 2:00 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/\" \/>\n<meta property=\"og:site_name\" content=\"System Admin [RESOLVED]\" \/>\n<meta property=\"article:published_time\" content=\"2014-05-15T21:35:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-05-16T01:32:57+00:00\" \/>\n<meta name=\"author\" content=\"Ed Rockwell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@EddieRock\" \/>\n<meta name=\"twitter:site\" content=\"@EddieRock\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ed Rockwell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/\"},\"author\":{\"name\":\"Ed Rockwell\",\"@id\":\"https:\/\/www.edrockwell.com\/blog\/#\/schema\/person\/e181b98aceccea720abee0c25bbfbcd7\"},\"headline\":\"SSH with Powershell: Backup multiple Cisco devices\",\"datePublished\":\"2014-05-15T21:35:25+00:00\",\"dateModified\":\"2014-05-16T01:32:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/\"},\"wordCount\":91,\"commentCount\":0,\"keywords\":[\"backup\",\"cisco\",\"Powershell\"],\"articleSection\":[\"Cisco\",\"PowerShell\",\"scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/\",\"url\":\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/\",\"name\":\"SSH with Powershell: Backup multiple Cisco devices - System Admin [RESOLVED]\",\"isPartOf\":{\"@id\":\"https:\/\/www.edrockwell.com\/blog\/#website\"},\"datePublished\":\"2014-05-15T21:35:25+00:00\",\"dateModified\":\"2014-05-16T01:32:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.edrockwell.com\/blog\/#\/schema\/person\/e181b98aceccea720abee0c25bbfbcd7\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.edrockwell.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SSH with Powershell: Backup multiple Cisco devices\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.edrockwell.com\/blog\/#website\",\"url\":\"https:\/\/www.edrockwell.com\/blog\/\",\"name\":\"System Admin [RESOLVED]\",\"description\":\"How To: Make My DevOps Life Easier\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.edrockwell.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.edrockwell.com\/blog\/#\/schema\/person\/e181b98aceccea720abee0c25bbfbcd7\",\"name\":\"Ed Rockwell\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/dea3152d7acd78aa28d280207c33f7ec516731ece9a54249cbbbebcfffc341e0?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dea3152d7acd78aa28d280207c33f7ec516731ece9a54249cbbbebcfffc341e0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/dea3152d7acd78aa28d280207c33f7ec516731ece9a54249cbbbebcfffc341e0?s=96&d=mm&r=g\",\"caption\":\"Ed Rockwell\"},\"sameAs\":[\"http:\/\/www.therockwells.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SSH with Powershell: Backup multiple Cisco devices - System Admin [RESOLVED]","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/","og_locale":"en_US","og_type":"article","og_title":"SSH with Powershell: Backup multiple Cisco devices - System Admin [RESOLVED]","og_description":"Today, I was asked to write a script to connect to all our Cisco devices and backup the configs to our fileserver. After a few hours of figuring it out, this is what I came up with You ONLY need a READ ONLY account on the Cisco devices. We run this every day at 2:00 [&hellip;]","og_url":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/","og_site_name":"System Admin [RESOLVED]","article_published_time":"2014-05-15T21:35:25+00:00","article_modified_time":"2014-05-16T01:32:57+00:00","author":"Ed Rockwell","twitter_card":"summary_large_image","twitter_creator":"@EddieRock","twitter_site":"@EddieRock","twitter_misc":{"Written by":"Ed Rockwell","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/#article","isPartOf":{"@id":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/"},"author":{"name":"Ed Rockwell","@id":"https:\/\/www.edrockwell.com\/blog\/#\/schema\/person\/e181b98aceccea720abee0c25bbfbcd7"},"headline":"SSH with Powershell: Backup multiple Cisco devices","datePublished":"2014-05-15T21:35:25+00:00","dateModified":"2014-05-16T01:32:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/"},"wordCount":91,"commentCount":0,"keywords":["backup","cisco","Powershell"],"articleSection":["Cisco","PowerShell","scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/","url":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/","name":"SSH with Powershell: Backup multiple Cisco devices - System Admin [RESOLVED]","isPartOf":{"@id":"https:\/\/www.edrockwell.com\/blog\/#website"},"datePublished":"2014-05-15T21:35:25+00:00","dateModified":"2014-05-16T01:32:57+00:00","author":{"@id":"https:\/\/www.edrockwell.com\/blog\/#\/schema\/person\/e181b98aceccea720abee0c25bbfbcd7"},"breadcrumb":{"@id":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.edrockwell.com\/blog\/ssh-powershell-backup-cisco-devices-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.edrockwell.com\/blog\/"},{"@type":"ListItem","position":2,"name":"SSH with Powershell: Backup multiple Cisco devices"}]},{"@type":"WebSite","@id":"https:\/\/www.edrockwell.com\/blog\/#website","url":"https:\/\/www.edrockwell.com\/blog\/","name":"System Admin [RESOLVED]","description":"How To: Make My DevOps Life Easier","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.edrockwell.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.edrockwell.com\/blog\/#\/schema\/person\/e181b98aceccea720abee0c25bbfbcd7","name":"Ed Rockwell","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dea3152d7acd78aa28d280207c33f7ec516731ece9a54249cbbbebcfffc341e0?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dea3152d7acd78aa28d280207c33f7ec516731ece9a54249cbbbebcfffc341e0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dea3152d7acd78aa28d280207c33f7ec516731ece9a54249cbbbebcfffc341e0?s=96&d=mm&r=g","caption":"Ed Rockwell"},"sameAs":["http:\/\/www.therockwells.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/comments?post=104"}],"version-history":[{"count":6,"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":112,"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/posts\/104\/revisions\/112"}],"wp:attachment":[{"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/media?parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/categories?post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.edrockwell.com\/blog\/wp-json\/wp\/v2\/tags?post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}