Questions tagged [copy-item]

Copy-Item is a powershell cmdlet that copies an item from one location to another.

Copy-Item is a powershell cmdlet that copies an item from one location to another in the same namespace. For example, it can copy a file to a folder, but it cannot copy a file to a certificate drive.

Copy-Item does not cut or delete the items being copied. The particular items that the cmdlet can copy depend on the Windows PowerShell provider that exposes the item. For example, it can copy files and directories in a file system drive and registry keys and entries in the registry drive.

Copy-Item can copy and rename items in the same command. To rename an item, enter the new name in the value of the Destination parameter. To rename an item without copying it, use the Rename-Item cmdlet.

Output

  • None or an object representing the copied item.
    When you use the PassThru parameter, Copy-Item returns an object that represents the copied item. Otherwise, this cmdlet does not generate any output.
282 questions
4
votes
1 answer

PowerShell: Copy-Item within PSSession ignores -Filter -Include -Exclude

Using the PowerShell command Copy-Item to copy files works fine locally, but when running it in a PSSession, the options -Filter, -Include and -Exclude show no effect while copying files from the remote host to the local machine. I am running…
Rantanplan
  • 180
  • 8
4
votes
2 answers

Copy-Item copies folder inside the target when running second time

During repetitive logs collection on my internal system, found strange behavior of recursive Copy-Item call Say, i have C:\Source with some files and subfolders with files. I want to copy this recursively to C:\Target. For first time all source will…
Max Shlain
  • 67
  • 1
  • 6
4
votes
1 answer

Solution for copying files between windows machines using different credentials

I work on a windows service application which can run scripts on a target machine. One of things I need to do is copy files over from my host machine to the target machine for different users. I have explored several solutions but have not found a…
Madhulika
  • 283
  • 3
  • 11
4
votes
1 answer

Copying a file on change using PowerShell

I am using a FileSystemWatcher to notify on file change, and then create a copy of that file: $watcher = New-Object System.IO.FileSystemWatcher $watcher.Path = "C:\Orders\" $watcher.IncludeSubdirectories = $false $watcher.EnableRaisingEvents =…
Mark Richman
  • 28,948
  • 25
  • 99
  • 159
4
votes
4 answers

Copy-Item Could not find part of path (with . in folder name)

I'm trying to use Copy-Item to copy a file to an existing folder and getting the error "Could not find part of path". I've Googled this problem for ages, but can't seem to find an answer. I altered the code to check that I could copy to each folder…
Matty W
  • 65
  • 1
  • 2
  • 8
4
votes
2 answers

How to force the copy of a file using powershell

I'm using powershell to copy file to a remote computer witht he following command : Copy-Item -Path [MyPath]\* -Destination \\[server]\[MyPath] -force It's working great, but sometime I'm receiving the following error message: "The process cannot…
4
votes
2 answers

Powershell: 'The fully qualified file name must be less than 260 characters'

I tried to use powershell command copy-item as xcopyto copy content of one disk to another one. copy-item -Path h:\* -Destination g:\ -Recurse -Force However, I encountered the following errors: Copy-Item : The specified path, file name, or both…
Loom
  • 9,768
  • 22
  • 60
  • 112
3
votes
1 answer

powershell error checking during file copy with recursion

I have a program that copies folders and files recursively. example: Copy-Item -path "$folderA" -destination "$folderB" -recurse Sometimes the files do not copy. Is there a way to "step inside the recursion" or a better way to do it, so I can…
alphadev
  • 1,529
  • 5
  • 18
  • 20
3
votes
1 answer

Passing the current File Path through to Powershell "SendTo" Script

I'm trying to create a script that will let me copy an item from one location to a specified location in a PowerShell script. Before it's mentioned, I know that I can put a shortcut in the Send To directory to perform this action, but I would like…
Austin Kargl
  • 89
  • 2
  • 10
3
votes
2 answers

Issue with mapping network drives using New-PSDrive

I am running a powershell based multithreaded application in which each thread (.net task) needs to copy a bunch of files from one machine to another with a different credential. This is the script which runs in each .net task New-PSDrive -Name tid…
Madhulika
  • 283
  • 3
  • 11
3
votes
1 answer

Odd Copy-Item powershell behaviour

I'm still a bit of a newbie at powershell (coming from vbscript) and it has been a while since I have done anything too serious, so I apologise in advance if the code isn't as graceful as it could be. Scenario is this: A system we use creates…
Pazu
  • 31
  • 2
3
votes
1 answer

Copying files and creating new folders based on "creationdate"

I am counting all files in my Pictures folder with Get-ChildItem C:\pictures -force | Group-Object extension | Sort-Object count -descending | ft count,name -auto I am then copying all my MTS-files (video) to a separate folder with Get-ChildItem…
Sune
  • 3,080
  • 16
  • 53
  • 64
2
votes
2 answers

Copy (append) multiple files into a single destination file

I'm having a weird issue with using PowerShell to merge multiple csv files into one. I've done this plenty of time in the cmd prompt on in windows 7, but here the output only contains the earliest file. The command is standard stuff: C:\> copy *.csv…
MWallace
  • 59
  • 6
2
votes
1 answer

Copy select items from one folder to a new folder

I am getting all wav files in the past 24 hours from one folder and putting them in another folder. I swear this worked for me a bit ago and wanted to add in some more conditional statements but now it is working. It is not creating a new folder for…
2
votes
2 answers

How to pipe directly to Copy-Item instead of within a ForEach-Object

Because the -Exclude parameter of Get-ChildItem is not filtering on subfolders when using the -Recurse flag, see among other unable-to-exclude-directory-using-get-childitem-exclude-parameter-in- powershell But the -Exclude parameter can be used to…
Bartel
  • 198
  • 1
  • 7
1
2
3
18 19