в моем конфиге устройства он имеет конфигурацию show running-config и start-up, которые оба настроены со строкой vty, такой как
show running-config
line vty 0 4
access-class 20 in
password 7 373737
login authentication test
exec-timeout 10
transport input ssh
line vty 5 15
access-class 20 in
password 7 373737
login authentication test
exec-timeout 10
start-up config
line vty 0 4
access-class 20 in
password 7 373737
login authentication test
exec-timeout 10
transport input ssh
line vty 5 15
access-class 20 in
password 7 373737
login authentication test
exec-timeout 10
transport input ssh
Я написал скрипт Powershell и регулярное выражение ниже, и когда язапускал скрипт, который выводил четыре раза.Я хочу сопоставить только первое совпадение и вывести только результат из рабочей конфигурации, но не знаю как.Может кто-нибудь помочь PLS?
$Line_VTY = Select-String -path c:\test\config.txt -Pattern "\sline\svty\s\d{1}\s\d{1,2} -Context 0,6
write-host $line_vty
и вывод показывает
line vty 0 4
access-class 20 in
password 7 373737
login authentication test
exec-timeout 10
transport input ssh
line vty 5 15
access-class 20 in
password 7 373737
login authentication test
exec-timeout 10
transport input ssh
line vty 0 4
access-class 20 in
password 7 373737
login authentication test
exec-timeout 10
transport input ssh
line vty 5 15
access-class 20 in
password 7 373737
login authentication test
exec-timeout 10
transport input ssh