I have a 50,000 folder names that uses numbers like 105671, 105672… and I need to insert the folder names into a SQL Server table. It takes almost 1 hours to do this.
This is my current powershell
$getTxt = Get-ChildItem “$FolderNP” -Directory -name | Out-File -filepath C:\KUMELLEN\NPList.txt
foreach($line in [System.IO.File]::ReadLines(“C:\KUMELLEN\NPList.txt”))
$NP_Folder_URL = $WIR_URL_NP+$line+"/"+$line+".htm"
$queryInsertNP = “insert into WIDS_ASS_SITE_DOC_PUBURL (SITE_REF, PUB_URL) values (’$line’, ‘$NP_Folder_URL’)”;
$Cmd.CommandText = $queryInsertNP;
$Result = $Cmd.ExecuteNonQuery()
How can I make this more efficient?
Appreciate your kind advise.