Hi Guys,
i have the following situation:
there aree 15 log files that contain data (text)
Each file is starting with some kind of header, i am only interested in the 3line.
The file contains value's (tekst) is written top to bottom, i am interested in the last line of the file, to be more specific the last value (text) that is after the ;
this is how a log file looks like
W
-10496
mnuPowerIn
63581203668;210,34
63581203728;203,46
63581203788;204,65
63581203848;206,15
63581203908;204,35
63581203968;198,97
another log file
W
-10496
mnuPower
63581203668;166,81
63581203728;165,45
63581203788;164,64
63581203848;165,18
63581203908;163,28
63581203968;159,21
63581204029;154,86
the output file shouls look like this:
mnuPowerIn:198,97
mnuPower:154,86
i am completely new with Powershell found some commands with but combining the command is a tough job.
last but not least i want this script to run each minute so the output file is always containing the actual values, it would be great if i can run it with a .cmd or .bat file
thanks in advanced
I made a code that almost do the trick
$input_path = ‘e:\A\*.tmp’
$fileDirectory = "e:\a"
$output_file = ‘e:\A\output.txt’
Clear-Content $output_file
foreach($file in Get-ChildItem $fileDirectory )
{
$filePath = $fileDirectory + "\" + $file;
$A = get-content -path $filePath | select -first 3 -last 1
Add-Content $output_file $A
}
it is not working flawless.
The output in the output file is different than the output in the console
console output:
A
-1146130
Inverter #2 - mnuCurrent
63581293796;0,83
Wh
-16728065
Inverter #2 - mnuTodayEnergy
63581293796;447,00
W
-10496
mnuPower
63581293796;153,78
W
-10496
Inverter #2 - mnuPower
63581293796;153,78
W
-10496
mnuPowerIn
63581293796;193,58
file output:
A
-1146130
Inverter #2 - mnuCurrent
63581293796;0,83
Wh
-16728065
Inverter #2 - mnuTodayEnergy
63581293796;447,00
A
-1146130
Inverter #2 - mnuCurrent
63581293796;447,00
W
-10496
mnuPower
63581293796;153,78
W
-10496
Inverter #2 - mnuPower
63581293796;153,78
i see a mnu current of 447,00 that is strange that is not on the console
any tips ?
i have it running now for test purposes, but i noticed that the script uses a lot of processor time, any idea's to make this script run faster ?