简体   繁体   English

如何延迟Complete-BitsTransfer直到传输完成?

[英]How to Delay Complete-BitsTransfer until Transfer Complete?

The following bits transfer starts a bunch of bits jobs, which work perfectly when I manually complete the transfer later: Get-BitsTransfer | Complete-BitsTransfer 以下位传输将启动一堆位工作,当我稍后手动完成传输时,这些工作会完美地工作: Get-BitsTransfer | Complete-BitsTransfer Get-BitsTransfer | Complete-BitsTransfer

My attempt to script a delay before complete is not working. 我尝试编写完成之前的延迟脚本不起作用。 The While is not processed, or perhaps it's processed before the transfer jobs even start. While未处理,或者可能在传输作业开始之前已处理。

loop starts many jobs...
    $job = Start-BitsTransfer -Source $fileUrl -Destination $fileDest -Asynchronous
...end loop

While ($job.JobState -eq "Transferring") {
    Sleep -Seconds 1
}

Get-BitsTransfer | Complete-BitsTransfer

Any suggestion how to permit -Asynchronous jobs a chance to load before executing complete? 有什么建议如何允许- -Asynchronous作业在执行完成之前有机会加载吗?

After I added a 1-second delay before the wait, the script above waits. 在等待之前添加了1秒的延迟后,上面的脚本等待。 Seems hacky. 似乎很老套。

cezarypiatek deserves this answer: cezarypiatek应该得到这个答案:

Problem is the While loop checking only the last package. 问题是While循环仅检查最后一个程序包。 Code corrected to: 代码已更正为:

$job - @()
loop starts many jobs...
    $job += Start-BitsTransfer -Source $fileUrl -Destination $fileDest -Asynchronous
...end loop

While ($job | Where-Object{$job.JobState -eq "Transferring"}) {
    Sleep -Seconds 1
}

Get-BitsTransfer | Complete-BitsTransfer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Complete-BitsTransfer cmdlet的用途是什么? - What is the purpose of the Complete-BitsTransfer cmdlet? Powershell BitsTransfer未完成 - Powershell BitsTransfer does not complete 在继续操作之前,如何让PowerShell等到命令完成? - How can I make PowerShell wait until a command is complete before proceeding? 等待所有线程完成,然后再运行下一个任务 - Wait until all threads complete before running next task 如何确定WebRequest何时完全完成? - How to find out when a WebRequest is fully complete? 如何以编程方式确定 Windows 安装程序是否完成 - How to determine if Windows Setup is complete programmatically 从 PowerShell 执行 .exe 文件并等待所有子进程完成 - Executing a .exe file from PowerShell and waiting until all child processes are complete Powershell Multijob脚本。 在作业完成时打开文件,而不是等待所有作业完成 - Powershell Multijob script. Make file open when job completes instead of waiting until all jobs complete 如何在powershell中使用默认会话凭证bitstransfer proxy - How to use use default session credentials bitstransfer proxy in powershell Powershell:如何获取通讯组的完整列表 - Powershell: How to obtain the complete list of distribution groups
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM