PowerShell - Remove all lines of text file until a certain string is found
问题 I currently have an output log file that's a bit of a mess and grows quickly. It's the debug output for a large script that permissions mailboxes. I basically just want to delete every line in the file until it finds the first iteration of the date 7days ago. So far, I can return all lines containing that date $content = Get-Content $file $lastweek = "{0:M/d/yyyy}" -f (get-date).AddDays(-7) $content | Where-Object { $_.Contains("$lastweek") } But I can not figure out a function to just wipe