Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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_File_Concurrency_Upload_Get Childitem - Fatal编程技术网

在powershell中上载时列出文件

在powershell中上载时列出文件,powershell,file,concurrency,upload,get-childitem,Powershell,File,Concurrency,Upload,Get Childitem,我想列出一个文件夹中的文件,而另一个文件正在上载到此文件夹中。但是当我提交代码时,它会等到上传完成后才执行命令。如何在不等待其他外部操作的情况下列出文件 $Path = "files\i\want\to\list\inside\the\folder" $List = Get-ChildItem $Path 下面是我要做的: Start-Job -Name "getList" -Scriptblock { $Path="files\i\want\to\list\inside\the\fo

我想列出一个文件夹中的文件,而另一个文件正在上载到此文件夹中。但是当我提交代码时,它会等到上传完成后才执行命令。如何在不等待其他外部操作的情况下列出文件

$Path = "files\i\want\to\list\inside\the\folder"
$List = Get-ChildItem $Path

下面是我要做的:

    Start-Job -Name "getList" -Scriptblock { $Path="files\i\want\to\list\inside\the\folder"; $pathList = Get-ChildItem $Path}
    $List = Receive-Job -Name "getList"
下面是它将要做的:

    Start-Job -Name "getList" -Scriptblock { $Path="files\i\want\to\list\inside\the\folder"; $pathList = Get-ChildItem $Path}
    $List = Receive-Job -Name "getList"
  • 创建在后台运行的作业,收集目录内容
  • 接收作业的内容并将其放入变量$List中
  • 当然,您可能希望使其成为一个内部循环作业,因此它将继续收集和替换数据。要停止它,可以使用
    stop Job-name“getList”


    这样,您就可以运行copy命令,然后接收目录数据。请记住,庞大的目录树会降低作业速度,从而降低数据刷新率。

    您需要使用某种并行性。查看
    Get Help about_Jobs
    Get Help Start Process
    ,以及PoshRSJob模块,了解各种方法。