Get the list of files that are getting copied in PowerShell

tusharmath picture tusharmath · Dec 11, 2012 · Viewed 30.3k times · Source

I am using the PowerShell Copy-Item command to copy a directory with files to another location.

I want to display all the files on the console that are getting copied so that I know the status of the copy command.

Answer

Jackie picture Jackie · Dec 11, 2012

If you just want to see that in console, use the -verbose switch:

copy-item -path $from -destination $to -verbose

If you want to get a list of files or directories:

$files = copy-item -path $from -destination $to -passthru | ?{$_ -is [system.io.fileinfo]}