I get a log file from an equipment to view a specific information. I already read the csv, but I don’t put de all lines of log to a foreach. The script is below:
I’m struggling to recognize what exactly you like to do with your code. You might describe that a little more detailed. You may post a few lines of your CSV files
(formatted as code as well please)
Regardless of that: Could you please try to avoid to post a lot of unnecessary white space? Thanks.
[pre]onu,gpon-1/1/5/25,GPON_DGi,Receive dying gasp of ONU,2019-09-01 05:46:42 UTC-3,false,CRITICAL
onu,gpon-1/1/5/37,GPON_DGi,Receive dying gasp of ONU,2019-08-14 10:32:29 UTC-3,false,CRITICAL[/pre]
I need to get the second and fifth columns: customer and time event respectively. Into Powershell code I am putting a label of columns and trying to create a foreach to put into a variable.
I didn’t understand this part of your code:
[pre] $ DGI = @ ’
un, gpon-1/1/5/25, GPON_DGi, receives a dying breath from the UN, 2019-09-01 05:46:42 UTC-3, false, CRITICAL
UN, gpon-1/1/5/37, GPON_DGi, receives a dying breath from the UN, 2019-08-14 10:32:29 UTC-3, false, CRITICAL
'@ | [/pre]
Do I need to put log content in plain text? Or is Working with a variable in which I import CSV?
Thank you in advance.
That’s just a way to deliver the data together with the code and make sure it works as intended. Of course you should use the Import-Csv you posted initially … like this:
$DGI = Import-Csv c:\DGI.CSV -Delimiter ‘,’ -Header device, port, alarm, description, time, status, severity |
Select-Object -Property port, time
$DGI
[pre]
<text>Clientes DGI:
gpon-1/1/2/39 2019-09-02 18:07:18 UTC-3
gpon-1/1/2/41 2019-09-02 16:48:25 UTC-3
gpon-1/1/5/22 2019-09-02 18:31:42 UTC-3
gpon-1/1/5/25 2019-09-01 05:46:42 UTC-3
gpon-1/1/5/37 2019-08-14 10:32:29 UTC-3
[/pre]
Now, I would like two things: remove the " UTC-3" and separate each group information with a Like that:
[pre]
[gpon-1/1/2/39 2019-09-02 18:07:18]
[gpon-1/1/2/41 2019-09-02 16:48:25]
[gpon-1/1/5/22 2019-09-02 18:31:42]
[gpon-1/1/5/25 2019-09-01 05:46:42]
[gpon-1/1/5/37 2019-08-14 10:32:29]
[/pre]