Hi everybody…<\/p>\n
I have an input file that´s like a log file… and I must read and convert the content to a csv or xls file acrross a powershell script…<\/p>\n
The content of log file is:<\/p>\n
[
\n{
\n“AccountId”: 0,
\n“RequestBody”: {},
\n“RequestLogId”: “20190624071155_074e4355-902a-4dac-abed-498c6b27809d”,
\n“Timestamp”: “2019-06-24T07:11:56.9462447-03:00”,
\n“Type”: “RequestLog”,
\n“Url”: “/WebServices/Conta/AccessControlWS.asmx/AuthenticateUser”,
\n“UserId”: 0,
\n“UserName”: “”
\n},
\n{
\n“AccountId”: 53,
\n“RequestLogId”: “20190624071155_074e4355-902a-4dac-abed-498c6b27809d”,
\n“Timestamp”: “2019-06-24T07:11:58.6650141-03:00”,
\n“Type”: “LoginLog”,
\n“Url”: null,
\n“UserId”: 627,
\n“UserName”: “Adriano”
\n},
\n{
\n“AccountId”: 53,
\n“RequestLogId”: “20190624071155_074e4355-902a-4dac-abed-498c6b27809d”,
\n“ResponseStatusCode”: 200,
\n“Timestamp”: “2019-06-24T07:11:58.8212494-03:00”,
\n“TotalRequestTime”: 3.0624525,
\n“Type”: “RequestCompleteLog”,
\n“Url”: “/WebServices/Conta/AccessControlWS.asmx/AuthenticateUser”,
\n“UserId”: 627,
\n“UserName”: “Adriano”
\n}<\/p>\n
]<\/p>\n
I want to run a powershell script to read this text file and output it to a csv or xls file using “AccountId”: “Timestamp”: “UserId”: “UserName”: as columns<\/p>\n
Does anyone have a idea on how to do this kind of parse?<\/p>","upvoteCount":2,"answerCount":5,"datePublished":"2019-07-02T15:28:22.000Z","author":{"@type":"Person","name":"sergiogludovats0476","url":"https://community.spiceworks.com/u/sergiogludovats0476"},"suggestedAnswer":[{"@type":"Answer","text":"
Hi everybody…<\/p>\n
I have an input file that´s like a log file… and I must read and convert the content to a csv or xls file acrross a powershell script…<\/p>\n
The content of log file is:<\/p>\n
[
\n{
\n“AccountId”: 0,
\n“RequestBody”: {},
\n“RequestLogId”: “20190624071155_074e4355-902a-4dac-abed-498c6b27809d”,
\n“Timestamp”: “2019-06-24T07:11:56.9462447-03:00”,
\n“Type”: “RequestLog”,
\n“Url”: “/WebServices/Conta/AccessControlWS.asmx/AuthenticateUser”,
\n“UserId”: 0,
\n“UserName”: “”
\n},
\n{
\n“AccountId”: 53,
\n“RequestLogId”: “20190624071155_074e4355-902a-4dac-abed-498c6b27809d”,
\n“Timestamp”: “2019-06-24T07:11:58.6650141-03:00”,
\n“Type”: “LoginLog”,
\n“Url”: null,
\n“UserId”: 627,
\n“UserName”: “Adriano”
\n},
\n{
\n“AccountId”: 53,
\n“RequestLogId”: “20190624071155_074e4355-902a-4dac-abed-498c6b27809d”,
\n“ResponseStatusCode”: 200,
\n“Timestamp”: “2019-06-24T07:11:58.8212494-03:00”,
\n“TotalRequestTime”: 3.0624525,
\n“Type”: “RequestCompleteLog”,
\n“Url”: “/WebServices/Conta/AccessControlWS.asmx/AuthenticateUser”,
\n“UserId”: 627,
\n“UserName”: “Adriano”
\n}<\/p>\n
]<\/p>\n
I want to run a powershell script to read this text file and output it to a csv or xls file using “AccountId”: “Timestamp”: “UserId”: “UserName”: as columns<\/p>\n
Does anyone have a idea on how to do this kind of parse?<\/p>","upvoteCount":2,"datePublished":"2019-07-02T15:28:22.000Z","url":"https://community.spiceworks.com/t/convert-text-file-with-delimiters-to-csv-or-xls/719171/1","author":{"@type":"Person","name":"sergiogludovats0476","url":"https://community.spiceworks.com/u/sergiogludovats0476"}},{"@type":"Answer","text":"
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n