I have multiple remote machines on a network that have a csv file on them stored in the same location that has been created by a powershell script.
Whats the best way to insert that data into a Microsoft Sql Server express database?
I have multiple remote machines on a network that have a csv file on them stored in the same location that has been created by a powershell script.
Whats the best way to insert that data into a Microsoft Sql Server express database?
One way of doing this is to collect all the CSV-files from all the servers to your script server. And then run the SQL INSERT query from the script server to put your data in an SQL table.
As described in one of my previous answers you can use this module Invoke-SQLCmd2 to do this.
The other way, when you don't want to collect all the CSV-files first, is running the SQL INSERT query from every server that has a CSV-file. To do this you have to connect to the other server and then import the module from the script server, so you can use it:
Import-Module -Name '\\SCRIPTSERVER\C$\Windows\system32\WindowsPowerShell\v1.0\Modules\Invoke-SQL'