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

Swift 3: Error in copying file with FileManager

I have a file named Data.plist in my main bundle (at the root of the app directory), and I am trying to copy this file to user document directory for read and write operations, however, I got the following error when trying to copy the…
TonyW
  • 18,375
  • 42
  • 110
  • 183
2
votes
3 answers

Copy-Item for copy files from local to remove server using credentials

I am trying to copy some files and folder from my local machine to a remote server: Copy-Item .\copy_test.txt -destination "\\serverip\c$\backups\" but I'm getting an error: Copy-Item : Logon failure: unknown user name or bad password. At line:1…
Robert
  • 10,403
  • 14
  • 67
  • 117
2
votes
1 answer

Does Copy-Item Change the type of Destination Parameter in PowerShell

I hope that this is a silly mistake and I am overlooking something really simple. I have a function to map a network drive and copy the contents of network drive to a destination. In the end, I return the destination path for re-use later. However,…
sohail
  • 589
  • 1
  • 11
  • 26
2
votes
3 answers

PowerShell mass copy to domain computers with multiple checks

I'm trying to copy a license file to all domain joined computers, and i am only able to use PowerShell. GPO or even (GPO) scheduled task is a no-go, because these don't seem to be possible yet within a Server 2003 environment. The application this…
Sha Gojyo
  • 21
  • 3
2
votes
0 answers

Copy-Item not working with Remote PowerShell to copy files from network share to local drive on remote server

Set-ExecutionPolicy -ExecutionPolicy Bypass $webServers = "remoteservername1" $deploymentCredentials = Get-Credential Invoke-Command -ComputerName $webServers -Credential $deploymentCredentials -ScriptBlock { $appVersionDirectory =…
2
votes
2 answers

Copy-Item Failing Given Paths format is not supported

This is driving me bananas. I am assuming I am missing something stupid, but I have tried about 10 different formats and nothing works. This is the code I am running: $today=$(Get-Date -Format o) $destfile =…
Webtron
  • 443
  • 2
  • 6
  • 18
2
votes
0 answers

copy a directory from a remote system to a USB drive replace a hardware image and then copy the directory back sounds simple enough

Thought this would be simple but.. i'm not a programmer im just trying to make something more efficient than having to re-type command after command on 20 systems mistakes happen. so what im trying to do is copy a directory from a remote system to a…
Doug
  • 21
  • 2
2
votes
1 answer

powershell Copy-Item Illegal characters in path

I am getting the following error from TeamCity when trying to execute a PowerShell script. Illegal characters in path. + CategoryInfo : NotSpecified: (:) [Copy-Item], ArgumentException + FullyQualifiedErrorId :…
mlibner
  • 23
  • 1
  • 4
2
votes
1 answer

Powershell equivalent of cp -n, i.e. copy files without overwriting

I frequently have to copy large numbers of files between drives, and the process often gets started and stopped. In a posix shell I can use cp -n to not overwrite existing files, but there doesn't seem to be an equivalent "do not overwrite" switch…
stib
  • 3,346
  • 2
  • 30
  • 38
2
votes
4 answers

Powershell Copy-Item - Exclude only if the file exists in destination

Following is the exact scenario in my powershell script. $Source = "C:\MyTestWebsite\" $Destination = "C:\inetpub\wwwroot\DemoSite" $ExcludeItems = @(".config", ".csproj") Copy-Item "$Source\*" -Destination "$Destination" -Exclude $ExcludeItems…
Nirman
  • 6,715
  • 19
  • 72
  • 139
2
votes
2 answers

PowerShell: Copy-Item throws DriveNotFoundException

My script keeps bugging me with the following exception copy-item : Cannot find drive. A drive with the name 'F' does not exist. At C:\Program Files (x86)\CA\ARCserve Backup\Templates\RB_Pre_Process.ps1:58 char:1 + copy-item -Path $drive…
Matthias Güntert
  • 4,013
  • 6
  • 41
  • 89
2
votes
1 answer

PowerShell Copy-Item what I'm doing wrong?

Given the dir structure: x\Code x\Script\Backup.ps1 Backup.ps1 contains: $BackupDirectoy = "..\Backup" $CodeDirectory = "..\Code" function BackupCurrentVersion() { New-Item $BackupDirectoy -type directory -force Copy-Item…
Victor Hurdugaci
  • 28,177
  • 5
  • 87
  • 103
2
votes
2 answers

Powershell script to copy and execute

Basically from a input provided network path (e.g "\SERVER\SHARE\") i want to copy a specific Excel file to my desktop and run it automatically. Problem is that on my desktop there are other Excel files containing the letters ZZZ. Any ideas? Thank…
Crit Scratch
  • 43
  • 1
  • 10
2
votes
1 answer

Why does the copyItemAtPath:toPath:userPath failed to copy the file when the file really exists? NSFileNoSuchFileError, Cocoa Error Code 4

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. if ([[UIDevice currentDevice] userInterfaceIdiom] ==…
Tooth Less
  • 21
  • 2
2
votes
1 answer

Why can't Powershell Copy-Item -Source -Destination to a UNC path known as a Variable see below

#VARIABLES $Source = Read-host "Please provide DIR location you wish to copy its contents from. ie. (UNC, Absolute paths, etc)" $Serverlist = Read-Host "Please provide the location of the server list. (UNC, Absolute paths, etc)" $Servers =…