Read file line by line in PowerShell

Not much documentation on PowerShell loops. Documentation on loops in PowerShell is plentiful, and you might want to check out the following help topics: about_For, about_ForEach, about_Do, about_While. foreach($line in Get-Content .\file.txt) { if($line -match $regex){ # Work here } } Another idiomatic PowerShell solution to your problem is to pipe the lines of the … Read more