How to get count of files copied using Copy-item

Hi,

I am using Copy-Item command to copy the multiple files from one location to another. In that, I want to get the count of files that are copied to destination.

If the above one is not possible, can we get ‘True’ if at least one file is copied and ‘False’ if none of the files are copied.
I tried this but could not able to get exact one.

Thanks,
Dinesh

Sure. Many commands, including Copy-Item, have a -PassThru parameter, which causes them to output the object they just acted against.

Copy-Item a b -PassThru | Measure-Object

By outputting the acted-upon objects, you can pipe them to Measure-Object to count them.

Thanks for the response. Its working as expected.