Avatar of A D
A D
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Poweshell Script to schedule

I have a folder named Error Log with thousands of txt files being logged by a third party application. Its difficult to find a specific error from those files and proactively fix related issues timely.

Can you help me with a powershell script which can search specific words from within those files in Error Log folder (e.g. '.' is missing or schema mismatch) and copy only those specific files to other folder named Status Errors?

I can then check Status Errors folder every evening and fix any errors so as to avoid any issues start of next day?
Powershell

Avatar of undefined
Last Comment
A D

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
oBdA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Qlemo

That still needs a correction:
Select-String -Path $source -Pattern $pattern  -List | Copy-Item -Path {$_.Path} -Destination $target -Verbose -WhatIf

Open in new window

-List is an optimization to only report the first match for each file. I didn' test whether it is optional or mandatory so files are copied only once.
Shaun Vermaak

or
copy *.txt combined.log

Open in new window

and then just inspect combined.log with something like TailBlazer
https://chocolatey.org/packages/tailblazer
A D

ASKER
ok thanks for your responses.. I'll check this today!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23