Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Powershell提高性能_Powershell - Fatal编程技术网

使用Powershell提高性能

使用Powershell提高性能,powershell,Powershell,我对Powershell脚本非常陌生。我有脚本从共享网络路径获取文件夹详细信息,如下所示。(例如,\\INTBMCELB\Transport\u Admin) 在从文本文件读取的每个网络路径中,都包含大量的数据。大约有2500个共享路径需要读取。目前大约需要2天的时间来完成。我可以提高性能更好吗 我是否可以对上述脚本添加任何更改,使执行时间小于当前总执行时间?瓶颈可能不在脚本中,而在缓慢作业的数量上。我建议并行执行此操作,尤其是当网络路径位于不同的计算机上时。查看一些工具的答案:我还建议在对其执

我对Powershell脚本非常陌生。我有脚本从共享网络路径获取文件夹详细信息,如下所示。(例如,
\\INTBMCELB\Transport\u Admin

在从文本文件读取的每个网络路径中,都包含大量的数据。大约有2500个共享路径需要读取。目前大约需要2天的时间来完成。我可以提高性能更好吗


我是否可以对上述脚本添加任何更改,使执行时间小于当前总执行时间?

瓶颈可能不在脚本中,而在缓慢作业的数量上。我建议并行执行此操作,尤其是当网络路径位于不同的计算机上时。查看一些工具的答案:我还建议在对其执行
Get ChildItem
之前检查
$dir
是否存在。因为在PS v3.0+中,缺少路径
Get ChildItem-Recurse
而在当前位置搜索(奇怪!)。如果它是,比如说,C:\,它确实需要时间,而且更可能不符合人们的愿望。
$infile = 'C:\Paths\PathList.txt'

$outdir = 'C:\Export\'

foreach ($dir in (Get-Content $infile)) 

{

$outfile =  Join-Path $outdir($dir -split '\\')[-1]

$outfilecsv=$outfile+'.csv'

Get-ChildItem -Path $dir -Filter *.* -Recurse | Select-Object FullName,CreationTime,@

{Name="Size";Expression={$_.Length}

} | Export-Csv -Path $outfilecsv -Encoding ascii -NoTypeInformation}