Last active
August 30, 2019 03:38
-
-
Save mark05e/73f534fe6ea9989dc347745f28c0f7d7 to your computer and use it in GitHub Desktop.
A crude log collection script in powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ref: https://stackoverflow.com/a/9587943/2854578 | |
$sourceDir = "C:\Users\mark\AppData\" | |
$targetDir = "E:\temp2\temptest\" | |
$includefiletype = @("*.log*", "*.log") | |
$startDateTime = "2019-08-29 8:18:00 PM" | |
$endDateTime = "2019-08-29 8:20:00 PM" | |
Get-ChildItem -Path $sourceDir -Include $includefiletype -Recurse | | |
Where-Object { $_.LastWriteTime -ge $startDateTime -and $_.LastWriteTime -le $endDateTime} | | |
ForEach { | |
$targetFile = $targetDir + $_.FullName.Substring($sourceDir.Length); | |
New-Item -ItemType Directory -Path $targetFile -Force | |
Copy-item $_.FullName -destination $targetfile -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment