Don’t do that #18: Use a loop For to get the line number

By | April 11, 2015

Don’t do that: You want to return the line number of a specific string “user04”.

File.txt

Code:


Do that: A faster method to return the line number is:

(Select-String -Path .\test.txt -Pattern 'user04').LineNumber


previous-buttonnext-button

Leave a Reply

Your email address will not be published.