매우 큰 서버에서 사용하기 위해 다음 코드의 속도를 높이는 방법이 필요합니다. 필요한 것은 fullname 매개 변수의 목록입니다. 내가 좋아하는 뭔가를 사용하고자하는 다음 http://newsqlblog.com/2012/05/22/concurrency-in-powershell-multi-threading-with-runspaces/Powershell GCI, 깊이 속도
어떻게 그것에 대해 읽고 있던 그것은 아주 간단 보인다, 그러나 나는 스레드가 기존 풀에 새로운 스레드를 만들 수 있도록 주위에 내 머리를 정리하고 수 없습니다 ... 그리고 그 수영장을 따라 가라.
어떤 도움도 좋을 것입니다. 왜냐하면이 속도는 끔찍하고 더 많은 자원을 가지고 있기 때문입니다.
Function Get-ChildItemToDepth {
Param(
[String]$Path = $PWD,
[int]$ToDepth = 255,
[Byte]$CurrentDepth = 0
)
if ($ToDepth -lt 0) {
return get-item $path
}
$CurrentDepth++
Get-ChildItem $Path | Where-Object { $_.PSIsContainer } | %{ $_
If ($CurrentDepth -le $ToDepth) {
Get-ChildItemToDepth -Path $_.FullName `
-ToDepth $ToDepth -CurrentDepth $CurrentDepth
}
}
}
참고 : 나는 2.0에
요약을 제한하고있다 : 나는 기본적으로 빨리 배열로 같은 디지털 가능 $ 깊이까지의 모든 폴더의 경로를해야합니다.
MISSERABLE 실패 시도 :
$func = `
{
Param(
[String]$Path = $PWD,
[int]$ToDepth = 255,
[Byte]$CurrentDepth = 0,
$p = $pool
)
if ($ToDepth -lt 0) {
return $path
}
$CurrentDepth++
$folders = Get-ChildItem $Path | Where-Object { $_.PSIsContainer } | select -expand FullName
If ($CurrentDepth -le $ToDepth) {
foreach ($path in $folders) {
$pipeline = [System.Management.Automation.PowerShell]::create()
$pipeline.RunspacePool = $pool
$pipeline.AddScript($func).AddArgument($path).AddArgument($ToDepth).AddArgument($CurrentDepth).AddArgument($pool)
$AsyncHandle = $pipeline.BeginInvoke()
$folders += $pipeline.EndInvoke($AsyncHandle)
$pipeline.Dispose()
}
}
return $folders
}
$path = "\\server\users-folder\"
$toDepth = 3
$pool = [RunspaceFactory]::CreateRunspacePool(1, 4)
$pool.ApartmentState = "STA"
$pool.Open()
$pipeline = [System.Management.Automation.PowerShell]::create()
$pipeline.RunspacePool = $pool
$pipeline.AddScript($func).AddArgument($path).AddArgument($toDepth).AddArgument($CurrentDepth).AddArgument($pool)
$AsyncHandle = $pipeline.BeginInvoke()
$RESULTS = $pipeline.EndInvoke($AsyncHandle)
$pipeline.Dispose()
$pool.Close()
, 나는 찬성 얻을-ChildItem을 포기 것 레거시 디렉터. cmd/c dir/b/ad/s는 gci보다 훨씬 빠르게 디렉토리 경로 목록을 반환합니다. –
mjolinor
덕분에 약간 도움이 될 것입니다. – TetraFlash
레거시 디렉터리는 특정 디렉토리에서 풀 패스로 폴더를 가져 오지 않을 것이며/s는 적절한 경로 이름을 제공하지만 특정 깊이에서 멈추지 않습니다. 관련 하위 폴더가 실제로 더 빠릅니까? – TetraFlash