I am trying to do the following:
- Look for a file in a folder which has been modified in the past 24 hours
- Find a specific section of the file
- Remove lines from the section matching specific string(s)
Here is the code I have so far:
$SummaryData = gci
| where {([datetime]::now - $_.lastwritetime).TotalHours -lt 24}
| get-content
| select-string 'SUMMARY' -context 0,10
| Where-Object {$_ -notmatch 'Files updated on right side'}
The code above returns no objects. However, if I remove | Where-Object {$_ -notmatch 'Files updated on right side'} it returns the full text:
> SUMMARY
------------------------------------------------------------------
Short Results: 15 copied (203.3GB)
Operation completed at 22:11:21 on 02/02/2013
Total duration: 01:01:49
Copied To Right Side: 15 (203.3GB)
Files updated on right side : 15
Transfer amount saved due to partial file updating : 196.2GB
Remaining actual transfer amount for eligible files: 7.1GB
Can someone tell me where I am going wrong please?
