Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to wait till copy complete using Powershell Copy-Item

I am copying files from One Windows machine to another using Copy-Item in Powershell script.

But I want to wait till copy completes, Powershell Copy-Item is non-blocking call means, it just triggers copy and returns to script however I want to wait till copy completes.

Is there any way to do it ?

like image 388
VarunVyas Avatar asked Aug 31 '12 07:08

VarunVyas


1 Answers

Maybe "copy-item [...] | out-null" will help to wait for completion.

"Out-null actually deletes output instead of routing it to the PowerShell console, so the script will sit and wait for the content to be deleted before moving on."

The explanation comes from ITProToday.com: https://www.itprotoday.com/powershell/forcing-powershell-wait-process-complete

like image 129
Fabi Avatar answered Oct 04 '22 11:10

Fabi