Compartilhar via


Log Parser Errors Importing into IIS Logs into SQL Server

 

During the transition of log parser scripts built in batch files to PowerShell, I encountered a few errors that took some time to figure out the cause and wanted to share with the rest of the universe.

Error 1:

The script is using the –oConnString switch to make the connection to the remote SQL Server. Received the error message IM002 Data Source name not found and no default driver specified.

image

At first, I was using the native driver {SQL Server Native Client 11.0} and switched to {SQL Server} and the import was successful.

Error 2:

During the issue with the –oConnString troubleshooting, I switched to native connection by specifying the SQL connection information without using the –ConnString switch as such:

-o:SQL -server:10.1.1.19 -database:IISLogManager -username:xxxxx -password:xxxxx Driver={SQL Server Native Client 11.0} -ignoreIdCols:ON -fixColNames:ON -createTable:On -transactionRowCount:-1

Received the error message SQL State 08001 Native Error 14

image

The very strange thing is the exact same log parser query worked in the command line and did not work through PowerShell.

I tried changing the SQL driver to {SQL Server} and it would still error out. Could not figure out the issue and changed the script to use the –oConnString with the correct SQL driver and was able to import into a remote SQL Server.