Guest User

Untitled

a guest
Feb 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. $Culture = [System.Globalization.CultureInfo]::InvariantCulture
  2. $Format = 'dd/MM/yyyy HH:mm:ss'
  3. $Paths = "D:xxxyyyylog.txt","D:xxxzzzzlog.txt"
  4. $Day = "20"
  5.  
  6. Foreach ($Path in $Paths)
  7. {
  8. Get-Content $Path | where { [datetime]::ParseExact(([string]$_).Substring(0,19), $format, $culture) -ge (Get-Date).AddDays(-$Day) } | set-content $Path".new"
  9. }
  10.  
  11. Get-Content $Path | if(!([string]$_)::IsNullOrEmpty) | where { ([datetime]::ParseExact(([string]$_).Substring(0,19), $format, $culture) -ge (Get-Date).AddDays(-$Day)) } | set-content $Path".new"
Add Comment
Please, Sign In to add comment