I have a script that retrieves metadata of files and uploads them to a SharePoint site. The problem is that there are around a million files and the process is really slow and I was wondering if there is a more efficient way of doing this.
The current script works like this
$ProjectName = Invoke-Sqlcmd -ServerInstance "Something" -Database "Something" -Query "SELECT * FROM something WHERE ID = 150
$Comments = Invoke-Sqlcmd -ServerInstance "Something" -Database "Something" -Query "SELECT * FROM something WHERE ID = 100
And then I manipulate the variables to upload them to SharePoint. The problem is that I have around 50 of these variables and the process is very slow, I imagine that the process can be faster by invoking/connecting to the database only once and iterating over the SQL queries but I am not too sure about how to do this.
I am a bit new to PowerShell so any help on this would be greatly appreciated, I just want to run SQL queries in bulk in one Invoke-Sqlcmd statement, is this possible?
Thank you in advance!