Hello everyone,
I'd like to ask you if it is possible (As I'm newbie in powershell) and how to extract data(specific lines) from a log (txt) and import them in excel.
Here the "problem" in details:
I receive every day a specific log file (in text) from an application that traces some transactions.
The log filename has the following format: LOGyyyymmddHHMM.log
Sometimes, I have an error message and I that's I need to extract and import it in an Excel file.
Here how it appears the lines in the log(not the real log as it is for a medical application):
"13/12/23 07:30:04 This is the error message. <The rest of the line, I want to discard it."
So, firstly I would like to insert in the excel file, in one column the date,in the other the hour that the error happened and on the third one the error message (in this case "This is the error message") and the rest of the line to be discarded.
Secondly I'd like to run this script every day at 02h00 for each new file based on it's name (file name given above) and add the results in the excel file.
And for the end, I need one excel file per month.
For the record, I tried this one but it misses a lot of code in order to accomplish that I need:
Set-ExecutionPolicy RemoteSigned
$mylog = Get-Content C:\CFT\LOG2013122323590018
$mylog | Select-String "This is the error message"
So, now $mylog contains all the lines with the error but as I explained above, I need some more.
Does anyone know if it is possible?
Thank you in advance Guys.