trying to write a PowerShell script to look for certain strings in a text file

Hi,
I am trying to write a PowerShell script to look for certain strings in a text file but not getting very far.,

What I want to do is:

  1. Search line by line until “set name 'Web Traffic Filter - General”’ is found then write line to file.

  2. Once found keep looking though the file for the next line with ‘set domain’ is found then write line to file.

  3. Once found keep looking though the file for the next line with ‘set type’ is found then write line to file.

  4. Once found keep looking though the file for the next line with ‘set action’ is found then write line to file.

  5. Repeat though file.

Example taken from file

set name “Web Traffic Filter - General”
config entries
edit 2
set domain “whois.com
set type wildcard
set action allow
next
edit 3
set domain “lufthansa.com
set type wildcard
set action allow
next
edit 4
set domain “partnerplusbenefit.com
set type wildcard
set action allow
next
edit 5
set domain “www.lufthansa.com
set action allow
next

julianhaines,
Welcome to the forum. :wave:t3:

This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

Regardless of that …

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you potentially wasting their time.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.