Hi Experts,
I am stuck in a code, my requirement is to get the lines between two strings, please suggest a regex pattern
Input:
Device Name: testStatus: Completed
Results:
[PUSH_TERMLET] Action completed successfully...
Pushing configuration file 'PUSH_TERMLET' for IDX 60504 with mechanism SSH
****** Enable Mode Results ******
sh run | sec ip access-list standard customer_internal
ip access-list standard customer_internal
permit 204.79.49.116
permit 159.12.130.0 0.0.0.31
permit 10.108.30.0 0.0.0.255
permit 10.108.141.0 0.0.0.127
permit 10.108.172.0 0.0.0.255
permit 10.108.160.0 0.0.0.31
zapesxr01#
Output:
permit 204.79.49.116
permit 159.12.130.0 0.0.0.31
permit 10.108.30.0 0.0.0.255
permit 10.108.141.0 0.0.0.127
permit 10.108.172.0 0.0.0.255
permit 10.108.160.0 0.0.0.31
Here is the code that i am trying
$content = Get-Content -Path "TestACL.txt" $device_list = $content | Select-String -Pattern "device name" -AllMatches foreach($temp in $device_list){ $temp.sp $pattern = "(?<=$temp|permit)(.*)" $content | Select-String -Pattern $pattern }
Awaiting a solution!