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.
Description. The Get-ChildItem cmdlet gets the items in one or more specified locations. If the item is a container, it gets the items inside the container, known as child items. You can use the Recurse parameter to get items in all child containers and use the Depth parameter to limit the number of levels to recurse.
xcopy is the windows command. It works with both PowerShell and cmd as well because it is a system32 utility command.
To copy items in PowerShell, one needs to use the Copy-Item cmdlet. When you use the Copy-Item, you need to provide the source file name and the destination file or folder name. In the below example, we will copy a single file from the D:\Temp to the D:\Temp1 location.
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]}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With