我编写了这个PowerShell脚本,它工作正常,但它需要55秒才能在一个文件上运行,但我需要运行435个文本文件,其中每个文件大约650 kB.
要完成435个文件需要7个小时!有没有办法让这个过程更快?也许把这个过程减半?我不知道问题是否是循环.
$Path = "C:\Users\rfp6fkj\Desktop\Group\*"
#OK so the Get-ChildItem cmdlet in Powershell creates an array to enumerate/loop thru
$Files = Get-ChildItem "$Path.Group"
(Get-Content $Path) -notmatch '^#' | Where { $_.Trim(" `t") } | Set-Content $Path
function GoParseandInsert {
try {
#$connection.Open()
$cmd = $connection.CreateCommand()
$insert_stmt = "INSERT INTO PasswordAge.[dbo].[tblDataParsed]
([Server]
,[Group]
,[UserID])
SELECT I.Server,[Group],F.Val AS TheUserID
FROM PasswordAge.[dbo].[GroupPasswordAge] I
CROSS APPLY PasswordAge.[dbo].ParseDelimValues(CASE WHEN I.UserID = '' THEN 'No Data in Column' ELSE I.UserID END,',') F
WHERE I.UserID <> ''" …Run Code Online (Sandbox Code Playgroud)