user4832990
user4832990

Reputation:

How does Copy-Item behave?

I'm in the process of learning PowerShell and I'm curious if someone can explain how Copy-Item works.

Specifically, let's say we copy a large item and that copy that will take 5 minutes to complete.

If this copy command was within a PowerShell script would the Copy-Item complete the copy before executing the next line or would the copy take place in the background and the script continuing execution?

So in the above example where it takes 5 minutes for the file to copy let's say the script looked like this -

Copy-Item C:\Example-Destination C:\Copy\Example-Destination
Write-Host "Copy Complete"

When the copy complete message is displayed would the copy have completed?

Upvotes: 2

Views: 954

Answers (1)

sodawillow
sodawillow

Reputation: 13176

When the copy complete message is displayed would the copy have completed?

Yes, when using PowerShell cmdlets, unless using jobs or anything specifically asynchronous, each command waits for the previous one to finish before running.

Upvotes: 2

Related Questions