foreach和Select-String不适用于大输入

时间:2016-04-16 13:17:16

标签: powershell foreach copy-item select-string

我在下面:

$users=get-content "1.txt"

foreach ($user in $users) {
  $source      = Select-String -Path 2.txt -Pattern "$user"
  $destination = Select-String -Path 3.txt -Pattern "$user"

  $src  = $source.Line
  $dest = $destination.Line

  Copy-Item $src $dest -Recurse -Force
} 

1.txt包含数千行,每行都有用户登录,2.txt3.txt包含数万行,其中UNC路径为-和{{1}包括在内。

.2.txt非常小时它正在工作但是一旦它们超过几十或几百个PowerShell就说它无法运行3.txt因为它无法使用系统对象作为字符串...错误是Copy-Item,它没有说明$dest

你能告诉我出了什么问题吗?我该怎么做?

0 个答案:

没有答案