Home > other >  Cisco config replace strings with Powershell
Cisco config replace strings with Powershell

Time:07-07

For security reasons, how can I replace the values after the word "secret"? Cisco config file extract:

enable secret 5 $1$362i$gx87nQDZq9RQxXWh2G5p//
!
username juanchis privilege 15 secret 5 $1$cGT9$uJ/rzNxjMvWJnUdPZahTS0

CodePudding user response:

Assuming your config is in a file called cisco.cfg:

Get-Content ./cisco.cfg | %{$_ -replace '(secret 5) .*','$1 <<ENCRYPTED PASSWORD REMOVED>>'}
  • Related