How to read powershell script file from log parser and save data in sql using c#?

Bascially,LogParser is used to read IIS logs.We upload one log file to log parser, select query and we get results of query like :user agent,ip address(basically hits to particular url).That query is PS(PowerShell Script) file.

Any idea how to read that PS file and save output of that query to db?

Asked by:- SnehalSawant
: 2390 At:- 11/19/2018 8:32:03 AM
C# SQL powershell script

1 Answers
profileImage Answered by:- jaya

As you have mentioned, you have powershell scripts to get logs, then you can run Powershell script using C#, and get result as List in C# then save it into database, here is the procedure step by step:

  1. Run the PS script using C#
  2. Get Result as List<SomeModel>
  3. Loop the above List and save data into SQL server database table as usual (Run powershell script using C#) (Run powershell script using C#) (Get Powershell result as List)

I think above links, should solve your issue.

At:- 11/19/2018 11:01:46 AM Updated at:- 11/19/2018 11:03:27 AM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use