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
2
votes
2 answers

[Powershell]: 2nd Execution of Copy-Item creates subfolder (5.1.17763.1007)

After searching for a wile I need to post my question here: I want to do a simple task: copy-item -path "C:\Folder Copied" -destination "C:\Folder Copied_New" -recurse Assuming the dir "Folder Copied_New" doenst exist in "C:", PS will create a…
Adis1102
  • 192
  • 1
  • 11
2
votes
2 answers

exclude path from get-childitem search

I'm trying to have all the files in the folder structure copied to a folder that is also part of that structure. So the destination folder is excluded form the search. I also want to exclude any folder that has in its path ".thumbnails" but when I…
2
votes
1 answer

Powershell copy-item creates a folder instead of copying file

I mapped a webdav folder with new-psdrive, cd to a folder, then try to copy one file to a local folder. The script code (draft) is the following: New-PSDrive -Name WEBDAV -PSProvider FileSystem -Root "\\testserver@SSL\davwwwroot\myApp" cd WEBDAV: cd…
Zoltan Hernyak
  • 989
  • 1
  • 14
  • 35
2
votes
0 answers

PowerShell Copy-Item and large files

I´m trying to copy a large file (around 180MB) to a remote server using PowerShell Copy-Item. Copy-Item –Path "$sourcePath" –Destination "$destPath" -Force –ToSession $session it works for files of arround 100MB, but i'm having issues with larger…
niva rojas
  • 101
  • 1
  • 10
2
votes
2 answers

Copy-item using Start-ThreadJob in Powershell

Off the back of this thread: Copy-item using invoke-async in Powershell I have the following: @mklement0's method (Copied from and amended by from here) works, but because it creates a thread per-file is exceptionally slow and on my test system…
AlexFielder
  • 137
  • 1
  • 12
2
votes
1 answer

Copy-item using invoke-async in Powershell

This article shows how to use Invoke-Async in PowerShell: https://sqljana.wordpress.com/2018/03/16/powershell-sql-server-run-in-parallel-collect-sql-results-with-print-output-from-across-your-sql-farm-fast/ I wish to run in parallel the copy-item…
AlexFielder
  • 137
  • 1
  • 12
2
votes
0 answers

Powershell Copy-Item does not keep folderstructure like intended

I try to use powershell to deploy a build (Visual Studio) to multiple remote server. The problem is, that the powershellscript does not copy the folders like I intendet to. I use the following powershell command to copy the published website to the…
Twiebie
  • 412
  • 1
  • 7
  • 16
2
votes
1 answer

Powershell Copy-Item destination is ambiguous

Assuming that "C:\Temp\first.txt" is a file, is there some way to ensure that Copy-Item -Path "C:\Temp\first.txt" -Destination "C:\Temp\second.txt" creates file "C:\Temp\second.txt", or else fails? If the destination, "C:\Temp\second.txt" already…
H6M6
  • 31
  • 1
2
votes
1 answer

Powershell Copy-Item Problems

I am trying to copy a user's profile from another drive to my C: drive. I have it down, but I ran into two problems that I keep banging my head against, but nothing is working for me. $user="JohnDoe" Copy-Item -Path "H:\$user\Contacts"…
Burainu
  • 35
  • 4
2
votes
2 answers

How To copy only new files from one folder to another with PowerShell

I'm having a little trouble finishing a powershell script. I have a program that downloads images into a temporary folder, then within an hour it will delete the image files. Occasionally I would like to keep some of the files so I'm creating a…
RayD
  • 85
  • 1
  • 2
  • 7
2
votes
1 answer

Kerberos Delegation Issue Copying Files to Remote Session with 2008 R2 Domain functional Level

When running the below code, i can put anything in the block at the bottom - I'm trying to copy a folder across to run an exe from a local folder and perform an install of that exe during the remote session to remote machines. I am getting Access…
Royston
  • 433
  • 2
  • 9
  • 25
2
votes
1 answer

Copy-Item from New-PSDrive within PSSession

I have the following Powershell code: Enter-PSSession -ComputerName test01 New-PSDrive -Name Source -PSProvider FileSystem -Root \\test02\SMBTest -Credential test\Administrator Copy-Item Source:\Test.txt -Destination C:\Temp Remove-PSDrive Source…
boomcubist
  • 770
  • 1
  • 7
  • 15
2
votes
1 answer

powershell - Copy-Item creates empty folder

I wanted to copy a bunch of jpg/gif files with starting Name into another location. It works not as intended. It creates addition folders which stays emtpy and do not copy all subfolders. Then I run again through the whole path and remove all empty…
Sven Bamberger
  • 899
  • 2
  • 10
  • 21
2
votes
4 answers

Copy-Item not including subfolder files of source directory in PowerShell

I have a script which moves files with a specific extension from a source directory to a destination directory. My source directory looks like: FILESFOLDER File1.td File2.td SUBFOLDER File3.td File4.td My script is short and looks…
Kahn Kah
  • 1,389
  • 7
  • 24
  • 49
2
votes
1 answer

Pipelined copy-item doesnt work after a file is renamed

I am quite new to PowerShell. I have created a PowerShell script which identifies a specific Mp3 file out of a large number of very similar files in one folder based on certain criteria: Is the most recent file created It is an MP3 file It has a…
IanB
  • 271
  • 3
  • 13
1 2
3
18 19